Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 18 additions & 20 deletions Report-Template.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Project Title
# Movie Info

Simple overview of use/purpose.
This a simple app that can be us used for generating movie or actor informations.

## Description

An in-depth paragraph about your project and overview of use.
This application has two menu. One for movie and another is for actors.
In movie menu you can take the imformations such as "release year", "imdb votes", "imdb rating" and "actors".
In actor menu you can see details of "net worth", "actor gender", "actor height", "actor birth" and "actor age or if she/he died, ypou can see the date of death".

## Getting Started
To start the program you should enter a valid name of a movie.

### Dependencies

* Describe any prerequisites, libraries, OS version, etc., needed before installing program.
* ex. Windows 10
First of all you should have java and nessary IDEs on your path.
To run this program you need to install Gradle. It let the app to use some special libraries.

### Installing
YOu can fork this files in git hub.
The URL code of this repository is "https://github.com/mahan-thm/Second-Assignment-CineScribe";

* How/where to download your program
* Any modifications needed to be made to files/folders

### Executing program

Expand All @@ -25,20 +26,17 @@ An in-depth paragraph about your project and overview of use.
```
code blocks for commands
```
At first you run the program, you see that it needs a name. You must enter a valid name of a movie to continue.
NOTE: if you enter any unvalid input to the program, an error will be accure and you should try again.
At the first menu (movie menu) there is a couple of option that gives you actor infoes.
In "actors", by entering the actor name, you can see the information of that actor.

## Help

Any advise for common problems or issues.
```
command to run if program contains helper info
```
## Help
This application have to connect to internet to export the datas. So dont forget to connect to a proper network.

## Authors

Contributors names and contact info

ex. Dominique Pizzie
ex. [@DomPizzie](https://twitter.com/dompizzie)
Email: m.tahmasbi1383@gmail.com

## Version History

Expand All @@ -53,7 +51,7 @@ ex. [@DomPizzie](https://twitter.com/dompizzie)
This project is licensed under the [NAME HERE] License - see the LICENSE.md file for details

## Acknowledgments

.
Inspiration, code snippets, etc.
* [awesome-readme](https://github.com/matiassingers/awesome-readme)
* [PurpleBooth](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2)
Expand Down
Empty file added src/.idea/.gitignore
Empty file.
6 changes: 6 additions & 0 deletions src/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions src/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 43 additions & 15 deletions src/main/java/Actors.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
import java.util.Scanner;
import org.json.JSONObject;

public class Actors {
public static final String API_KEY = "Your API_KEY"; // TODO --> add your api key about Actors here
public static final String API_KEY = "W+vh5nItJvK8jXhbKH2x0g==JJe0UK88tZZBGS1n"; // TODO --> add your api key about Actors here
String netWorth;
Boolean isAlive;

public Actors(String netWorth, boolean isAlive){
public Actors(String netWorth, boolean isAlive) {
//TODO --> (Write a proper constructor using the get_from_api functions)
this.netWorth = netWorth;
this.isAlive = isAlive;
}

@SuppressWarnings({"deprecation"})
/**
* Retrieves data for the specified actor.
Expand All @@ -19,8 +25,8 @@ public Actors(String netWorth, boolean isAlive){
*/
public String getActorData(String name) {
try {
URL url = new URL("https://api.api-ninjas.com/v1/celebrity?name="+
name.replace(" ", "+")+"&apikey="+API_KEY);
URL url = new URL("https://api.api-ninjas.com/v1/celebrity?name=" +
name.replace(" ", "+") + "&apikey=" + API_KEY);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("X-Api-Key", API_KEY);
System.out.println(connection);
Expand All @@ -34,7 +40,9 @@ public String getActorData(String name) {
}

in.close();
return response.toString();
String res = response.toString();
res = res.substring(1, res.length() - 1);
return res;
} else {
return "Error: " + connection.getResponseCode() + " " + connection.getResponseMessage();
}
Expand All @@ -43,22 +51,42 @@ public String getActorData(String name) {
return null;
}
}
public double getNetWorthViaApi(String actorsInfoJson){
//TODO --> (This function must return the "NetWorth")
double result = 0.0;
return result;


public String getNameViaApi(String actorsInfoJson) {
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getString("name");
}
public double getNetWorthViaApi(String actorsInfoJson) {
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getDouble("net_worth");
}
public String getGenderViaApi(String actorsInfoJson) {
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getString("gender");
}public float getHeightViaApi(String actorsInfoJson) {
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getFloat("height");
}public String getDateOfBirthViaApi(String actorsInfoJson) {
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getString("birthday");
}public int getAgeViaApi(String actorsInfoJson) {
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getInt("age");
}

public boolean isAlive(String actorsInfoJson){


public boolean isAlive(String actorsInfoJson) {
//TODO --> (If your chosen actor is alive it must return true otherwise it must return false)
boolean statues = false;
return statues;
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getBoolean("is_alive");
}

public String getDateOfDeathViaApi(String actorsInfoJson){
public String getDateOfDeathViaApi(String actorsInfoJson) {
//TODO --> (If your chosen actor is deceased it must return the date of death) -->
String date = "";
return date;
JSONObject jason = new JSONObject(actorsInfoJson);
return jason.getString("death");
}

}
114 changes: 112 additions & 2 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,119 @@
import java.util.ArrayList;
import java.util.Scanner;

public class Main {


public static void main(String[] args) {
// TODO --> complete main function
runMenu();
Scanner input = new Scanner(System.in);
Movie myMovie = new Movie(new ArrayList<>(), "", 0);
boolean secondWhileBreak = false;
System.out.println("Give me a name of a movie!");
while (true) {
String movieName = input.nextLine();
String movieJson = myMovie.getMovieData(movieName);
if (movieJson == "{\"Response\":\"False\",\"Error\":\"Movie not found!\"}") {
System.out.println("invalid name... Movie not found");
continue;
}
while (true) {
System.out.println("1. selected movie\n2. year\n3. imdb votes\n4. imdb rating\n5. actors\n6. select another movie\n7. EXIT");
int movieMenuOrder = Integer.valueOf(input.nextLine());
if (movieMenuOrder == 6) {
break;
} else if (movieMenuOrder == 7) {
secondWhileBreak = true;
break;
}
runMovieMenu(movieName, movieMenuOrder);
}
if (secondWhileBreak) {
break;
}
}

}
public static void runMenu() {


public static void runMovieMenu(String name, int order) {
Movie myMovie = new Movie(new ArrayList<>(), "", 0);
String movieJson = myMovie.getMovieData(name);

switch (order) {
case 1:
System.out.println(myMovie.getTitleViaApi(movieJson));
break;
case 2:
System.out.println(myMovie.getYearViaApi(movieJson));
break;
case 3:
System.out.println(myMovie.getImdbVotesViaApi(movieJson));
break;
case 4:
System.out.println(myMovie.getRatingViaApi(movieJson));
break;
case 5:
System.out.println(myMovie.getActorListViaApi(movieJson));
System.out.println("Type the actor name to see actor info");
Scanner input = new Scanner(System.in);
while (true) {
String actorName = input.nextLine();
Actors myActor = new Actors(name, true);
String actorJson = myActor.getActorData(name);
if (actorJson == null) {
System.out.println("ERROR: Invalid name... Actor not found");
continue;
}
System.out.println("1. selected actor\n2. net worth\n3. gender\n4. height\n5. birth\n6. age or date of death\n7. BACK");
while (true) {
int actorMenuOrder = Integer.valueOf(input.nextLine());
runActorMenu(actorName, actorMenuOrder);

}

}
}
return;
}


public static void runActorMenu(String name, int order) {
// TODO
Actors myActor = new Actors(name, true);
String json = myActor.getActorData(name);
Actors estefade = new Actors(name, true);

switch (order) {
case 1:
System.out.println(myActor.getNameViaApi(json));
break;
case 2:
System.out.println(myActor.getNetWorthViaApi(json));
break;
case 3:
System.out.println(myActor.getGenderViaApi(json));
break;
case 4:
System.out.println(myActor.getHeightViaApi(json));
break;
case 5:
System.out.println(myActor.getDateOfBirthViaApi(json));
break;
case 6:
if (myActor.isAlive(json))
System.out.println(myActor.getAgeViaApi(json));
else if (!myActor.isAlive(json))
System.out.println(myActor.getDateOfDeathViaApi(json));
break;
default:
System.out.println("invalid choice");
break;
}

// String inputName = "ana de armas";
// String result = myActor.getActorData(inputName);
// System.out.println(result);
// System.out.println(myActor.getNetWorthViaApi(result));
}
}
Loading