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
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

41 changes: 20 additions & 21 deletions Report-Template.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
# Project Title

Simple overview of use/purpose.
Movie and Actor database

## Description

An in-depth paragraph about your project and overview of use.
In this program, you enter the name of the movie or actor and receive the information of them.

## Getting Started

ArrayList, JSONArray, JSONNObject
### Dependencies

* Describe any prerequisites, libraries, OS version, etc., needed before installing program.
* ex. Windows 10
you shoud get Gradle version 8.5 in this program you nead thid libraries:
ArrayList, JSONObject, IOException, InputStreamReader, net.URLConnection, io.BufferedReader and net.HttpURLConnection.

### Installing

* How/where to download your program
* Any modifications needed to be made to files/folders
If you see this program you should install intellij and if you run this program you should install Gradle too.

### Executing program

* How to run the program
* Step-by-step bullets
```
code blocks for commands
```
After installing the program, enter the program file and open the main part, then press the green triangle next to the main function and the program will run like this.


## Help

Any advise for common problems or issues.
```
command to run if program contains helper info
```
To learn better "API", you can refer to Jadi's YouTube channel. You can use the following sites to learn programing better.
Code School... .

## Authors

Contributors names and contact info

ex. Dominique Pizzie
Mohaddeseh Ganjkhanlou: Student of SBU. ex. Dominique Pizzie
ex. [@DomPizzie](https://twitter.com/dompizzie)

## Version History

* 0.2
* Various bug fixes and optimizations
* See [commit change]() or See [release history]()
* Various bug fixes and optimizations
* See [commit change]() or See [release history]()
* 0.1
* Initial Release
* Initial Release

## License

This project is licensed under the [NAME HERE] License - see the LICENSE.md file for details
https://omdbapi.com/ (for movie)

https://api-ninjas.com/api/celebrity (for celebrity)

https://www.bing.com/videos/riverview/relatedvideo?&q=how+to+take+API+with+JSON+in+java+on+grdle&&mid=D193646A9484D3F83B3DD193646A9484D3F83B3D&mmscn=mtsc&aps=0&FORM=VRDGAR

https://www.bing.com/videos/riverview/relatedvideo?q=%D9%88%DB%8C%D8%AF%DB%8C%D9%88%D9%87%D8%A7%DB%8C%20%D8%AC%D8%A7%D8%AF%DB%8C%20%D8%AF%D8%B1%20%DB%8C%D9%88%D8%AA%DB%8C%D9%88%D8%A8&mid=07413B5CF9A564AAFA9D07413B5CF9A564AAFA9D&ajaxhist=0
## Acknowledgments

Inspiration, code snippets, etc.
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/.idea/.gitignore

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

6 changes: 6 additions & 0 deletions src/main/java/.idea/misc.xml

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

8 changes: 8 additions & 0 deletions src/main/java/.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/main/java/.idea/vcs.xml

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

110 changes: 98 additions & 12 deletions src/main/java/Actors.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
import org.json.JSONObject;
public class Actors {
public static final String API_KEY = "Your API_KEY"; // TODO --> add your api key about Actors here
String netWorth;
Boolean isAlive;
public static final String API_KEY = "lx3V7SSX0UGbFy8DibPSfQ==fbNjG3un4zdTPqV3";
double netWorth;
String date_birth;
String gender;
double height;
Boolean status;
String date;

public Actors(String netWorth, boolean isAlive){
//TODO --> (Write a proper constructor using the get_from_api functions)
public Actors(double netWorth, String date_birth, String gender, double height, boolean status, String date){
this.netWorth = netWorth;
this.date_birth = date_birth;
this.gender = gender;
this.height = height;
this.status = status;
this.date = date;
}
@SuppressWarnings({"deprecation"})
/**
Expand All @@ -34,7 +44,7 @@ public String getActorData(String name) {
}

in.close();
return response.toString();
return response.toString().substring(1, response.toString().length() - 1);
} else {
return "Error: " + connection.getResponseCode() + " " + connection.getResponseMessage();
}
Expand All @@ -45,20 +55,96 @@ public String getActorData(String name) {
}
public double getNetWorthViaApi(String actorsInfoJson){
//TODO --> (This function must return the "NetWorth")
double result = 0.0;
return result;
double netWorth = 0.0;
try {
JSONObject netWorthObject = new JSONObject(actorsInfoJson);
netWorth = netWorthObject.getDouble("net_worth");
System.out.println("Net Worth: " + netWorth);
} catch (Exception e) {
e.printStackTrace();
}
return netWorth;
}

public String getDataOfBirth(String actorsInfoJson)
{
String date_birth = "";
try {
JSONObject Date = new JSONObject(actorsInfoJson);
if(Date.has("birthday"))
{
date_birth = Date.getString("birthday");
}
}
catch (Exception e)
{
e.printStackTrace();
}
return "Birthday: " + date_birth;
}
public String getGender(String moviesInfoJson)
{
String gender = "";
try
{
JSONObject Actors_Gender = new JSONObject(moviesInfoJson);
if(Actors_Gender.has("genre"))
{
gender = Actors_Gender.getString("Gender");
}
}
catch (Exception e)
{
e.printStackTrace();
}
return "Gender: " + gender;
}

public double getHeight(String actorsInfoJson)
{
double height = 0.0;
try
{
JSONObject height_object = new JSONObject(actorsInfoJson);
height = height_object.getDouble("height");
System.out.println("Height_Of_Person: " + height);
}
catch (Exception e)
{
e.printStackTrace();
}
return height;
}

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;
boolean status = false;
try {
JSONObject live = new JSONObject(actorsInfoJson);
status = live.getBoolean("is_alive");
System.out.println("Is Alive: "+ status);
} catch (Exception e) {
e.printStackTrace();
}
return status;
}

public String getDateOfDeathViaApi(String actorsInfoJson){
//TODO --> (If your chosen actor is deceased it must return the date of death) -->
String date = "";
try {
JSONObject Date_Of_Death = new JSONObject(actorsInfoJson);
if(Date_Of_Death.has("death"))
{
date = Date_Of_Death.getString("death");
System.out.println("death: "+ date);
}

} catch (Exception e) {
e.printStackTrace();
}
return date;
}

}

}

71 changes: 68 additions & 3 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,74 @@
import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
// TODO --> complete main function
runMenu();
}
public static void runMenu() {
// TODO
public static void runMenu() throws IOException {
while (true)
{
Scanner input = new Scanner(System.in);
System.out.println("Hi, Welcome Movie and Actor database. In this program, you enter the name of the movie or actor and receive the information of them.");
System.out.println("1. Movie");
System.out.println("2. Actors");
int choice = input.nextInt();
switch (choice) {
case 1:
Movie movie_object = new Movie(new ArrayList<>(), "", 0, "", "", "", "", "", "", "", "", "", "", "");
System.out.println("Enter name of Movie: ");
Scanner Input_Movie = new Scanner(System.in);
String FilmName = Input_Movie.nextLine();
String check = movie_object.getMovieData(FilmName);
while (check.equals("Please check movies name!"))
{
FilmName = input.next();
check = movie_object.getMovieData(FilmName);

}
System.out.println(FilmName);
System.out.println(movie_object.getYear(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getRatingViaApi(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getReleased(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getGenre(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getRuntime(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getDirector(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getAuthor(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getPlot(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getLanguage(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getCountry(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getType(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getActorListViaApi(movie_object.getMovieData(FilmName)));
System.out.println(movie_object.getImdbVotesViaApi(movie_object.getMovieData(FilmName)));
break;
case 2:
Actors actors_object = new Actors(0.0, "", "", 0.0, false, "");
System.out.println("Enter name of Actor: ");
Scanner input_actor = new Scanner(System.in);
String ActorName = input_actor.next();
String Check = actors_object.getActorData(ActorName);
while (Check.equals("Please check actor name!"))
{
ActorName = input.next();
Check = actors_object.getActorData(ActorName);

}
System.out.println(ActorName);
System.out.println(actors_object.getNetWorthViaApi(actors_object.getActorData(ActorName)));
System.out.println(actors_object.getDataOfBirth(actors_object.getActorData(ActorName)));
System.out.println(actors_object.getGender(actors_object.getActorData(ActorName)));
System.out.println(actors_object.getHeight(actors_object.getActorData(ActorName)));
System.out.println(actors_object.isAlive(actors_object.getActorData(ActorName)));
System.out.println(actors_object.getDateOfDeathViaApi(actors_object.getActorData(ActorName)));
break;
default:
System.out.println("Invalid choice. Please select a valid option!");
}
}

}
}
Loading