Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA You are the software developer put in charge of helping an online streaming

ID: 665814 • Letter: J

Question

JAVA

You are the software developer put in charge of helping an online streaming website to categorize its film collection. The company already has an existing collection of American films, but it wants to branch out into foreign films. While the company plans to have foreign films from many countries it plans to especially expand into Bollywood films. These films are from India and are primarily in Hindi, but they sometimes also have other secondary languages that are spoken in the films. Most Bollywood films are also musicals.

Once you take a look at their software you realize that they have not used object-oriented programming. The software they have is very difficult to reuse and update. You decide that you will have to create a new design for the software and start completely from scratch.

The development of this project must be done using object-oriented programming. All films should contain name of the film, name of the director, and year of release. All foreign films are films but also have language the film is in, subtitle information, and translation of the film name into English. There can be more than one subtitle for a movie (imagine a film in French that has English and Spanish subtitles). There can also be more than one director of a film. Bollywood films are foreign films that have songs and may have secondary languages as well.

There should ways to access and mutate all the information stored. Inheritance must be used to accomplish this assignment. There should be a parent class for films and a class which inherits from that class and represents foreign films and class that represents Bollywood films which inherits from foreign films.

In addition to the requirements above, each film class must override the toString method inherited from the Object class. The overridden definition of each toString method should return all the information stored about that specific film. The parent class for films must also override the equals method inherited from the Object class. This method should determine whether two films are the same. If they are the same it should return true otherwise return false.

Finally, demonstrate a prototype of this program by allowing the user to either create up to ten films (an array of films). Provide the user with a menu of options to create a film, foreign film, or Bollywood film. Once a film is created it should be stored so that it can be accessed
again. There should be an option to display all the information for all films entered so far. Use the toString method to display the information for each film. After a user enters a film use the equals method in the film class to make sure that film has not already been entered into the system. If it has tell the user that film already exists in the system and do not store it again. If it has not been entered then insert it into the system.

You may use any films to test your system, but make sure to include at least one film, one foreign film, and one Bollywood film, and at least five films. If you are not familiar with films or foreign films or Bollywood films a list is provided below so that you use these films to test your program.

Film

Name of Film: The Matrix
Name of Director(s): Andy Wachowski, Lana Wachowski Year of Release: 1999

Foreign Film

Name: Densha Otoko
Name of Director(s): Shosuke Murakami Year of Release: 2005

Language: Japanese
Subtitle Information: English Translation: Train Man

Bollywood Film

Name of Film: Veer-Zaara
Name of Director(s): Yash Chopra Year of Release: 2004

Language: Hindi
Secondary Language (if any): Urdu, Punjabi
Subtitle Information: English, Arabic, Tamil, Telugu Translation: Veer-Zaara

Songs:
1) "Tere Liye"
2) "Main Yahan Hoon"
3) "Aisa Des Hai Mera"
4) "Yeh Hum Aa Gaye Hain Kahan" 5) "Do Pal"
6) "Kyon Hawa"
7) "Hum To Bhai Jaise"
8) "Aaya Tere Dar Par"
9) "Lodi"
10) "Tum Paas Aa Raahein Ho"
11) "Jaane Kyon"

Bollywood Film

Name of Film: Pyaasa
Name of Director(s): Guru Dutt Year of Release: 1957

Language: Hindi
Secondary Language (if any): none Subtitle Information: English Translation: Thirsty

Songs:
1) "Aaj Sajan Mohe Ang Lagalo"
2) "Ham Aapki Aankhon Me"
3) "Jaane Kya Tune Kahi"
4) "Jane Woh Kaise Log"
5) "Sar Jo Tera Chakraye"
6) "Yeh Duniya Agar Mil Bhi Jaaye Toh Kya Hai"
7) "Ye Hanste Huye Phool"
8) "Jinhen Naaz Hai Hind Par"
9) "Tang Aa Chuke Hain Kashm-e-Kashe Zindagi Se"

Bollywood Film

Name of Film: 3 Idiots
Name of Director(s): Rajkumar Hirani Year of Release: 2009

Language: Hindi
Secondary Language (if any): Urdu, English Subtitle Information: English, French, Spanish Translation: 3 Idiots

Songs:
1) "Aal Izz Well"
2) "Zoobi Doobi"
3) "Behti Hawa Sa Tha Woh" 4) "Give Me Some Sunshine" 5) "Jaane Nahin Denge Tujhe" 6) "Zoobi Doobi - Remix"
7) "Aal Izz Well - Remix"

Explanation / Answer

/*The java class File contains methods to set film name, director and year.
* Overirdes the toString method to print film details*/
//Film.java
public class Film
{  
  
   //private variables of class Film
   private String filmName;
   private String director;
   private int yearOfRelease;

   //default constructor
   public Film()
   {
       filmName="none";
       director="none";
       yearOfRelease=0;
   }


   //parameterized constructor
   public Film(String filmName,String director,int yearOfRelease)
   {
       this.filmName=filmName;
       this.director=director;
       this.yearOfRelease=yearOfRelease;
   }
  
   public void setName(String filmName)
   {
       this.filmName=filmName;
   }
  
   public String getName()
   {
       return filmName;
   }
  
   public void setDirector(String director)
   {
       this.director=director;
   }
  
   public String getDirector()
   {
       return director;
   }
  
   public void setYear(int yearOfRelease )
   {
       this.yearOfRelease=yearOfRelease;
   }
  
   public int getyearOfRelease()
   {
       return yearOfRelease;
   }
  
   //Override equals method
   @Override
   public boolean equals(Object obj)
   {
       Film film=(Film)obj;
       return filmName.equals(film.getName()) &&
               director.equals(film.getDirector()) &&
               yearOfRelease==film.getyearOfRelease();
   }
  
   //Override toString method to returns
   //string representation of film details
   @Override
   public String toString() {
      
       String strFilm="";
       strFilm="Name of Film:"+filmName+" "+
       "Name of Director(s):"+director+""+
               "Year of Release :"+yearOfRelease;
       return strFilm;
   }

}


------------------------------------------------------------------------------------------------------------------------------------------

/*The java class ForeignFilm extends the class Film
* and has methods to set language and subtitle and
* Overirdes the toString method to print film details*/

//ForeignFilm.java

import java.util.ArrayList;
public class ForeignFilm extends Film
{  
   private String language;
   protected ArrayList<String> subTitle=new ArrayList<String>();
   private String translation;
  
   //parameterized constructor
   public ForeignFilm(String filmName,String director,int yearOfRelease,
           String language,String translation)
   {
       //calling super class constructor
       super(filmName, director, yearOfRelease);
       //sets language
       this.language=language;
       //sets the translation
       this.translation=translation;      
   }
  
   //Method to add subtitle to the array list subTitle
   public void addSubtitle(String subtitle)
   {
       subTitle.add(subtitle);
   }
  
  
  
   //Returns the string representaion of the ForeignFilm object
   @Override
   public String toString()
   {
       String foreignFile="";
      
       foreignFile= super.toString();
      
       foreignFile+=" Language:"+language+
               " Subtitle Information:"+subTitle.toString()+
               "Translation: "+translation;
      
       return foreignFile;
   }
  
  
}

------------------------------------------------------------------------------------------------------------------------------------------

//BollywoodFilm.java

/* The java class BollywoodFilm inherits from the class ForignFilm class.
* Overirdes the toString method to print bollywodd film details*/
import java.util.ArrayList;
public class BollywoodFilm extends ForeignFilm
{
  
   //Create two array lists to store second language and songs list
   private ArrayList<String>secondLanList=new ArrayList<String>();
   private ArrayList<String>songsList=new ArrayList<String>();
  
  
  
   //constructor to set the details of the bolllywood file
   public BollywoodFilm(String filmName,String director,int yearOfRelease,
           String language,String translation)
   {
       //calling super class Foreign film constructor
       super(filmName, director, yearOfRelease, language, translation);      
   }
  
  
   //Method to add subtitles
   public void addSubtitle(String subtitle)
   {
       subTitle.add(subtitle);
   }
  
  
   //Method to add secondary language
   public void addSecondLanguage(String secondLaguage)
   {
       secondLanList.add(secondLaguage);
   }
  
  
   //Method to add song name
   public void addSong(String songName)
   {
       songsList.add(songName);
   }
      
   //Returns the string representaion of Bollywood film details
   @Override
   public String toString()
   {
      
       String bollyWoodMovie="";
       bollyWoodMovie=super.toString();
      
       bollyWoodMovie+=" Secondary Languages(if any)"+secondLanList.toString();
       bollyWoodMovie+=" Songs: "+songsList.toString();
      
       return bollyWoodMovie;
   }  
}//end of the class BollywoodFilm

------------------------------------------------------------------------------------------------------------------------------------------

/*The Driver java class that demonstrates the three
* classes Filem,ForeignFilm and BollywoodFilm classes
* with constructor arguments and prints the details
* */


//Driver.java

import java.util.Scanner;
public class Driver
{
   public static void main(String[] args)
   {

       final int size=10;
       int userChoice;
       //create an array of Film
       Film[] films=new Film[size];
       Scanner scaner=new Scanner(System.in);

       int index=0;

       String filmName;
       String director;
       int yearOfRelease;
       String language;
       String subTitle;
       String translation;
       String secondLanguage;
       String song;
       char ch;

       do
       {

           userChoice=menu();

           switch (userChoice)
           {
           case 1:      
               System.out.println("Enter film name");
               filmName=scaner.nextLine();
               System.out.println("Enter direcitor name");
               director=scaner.nextLine();
               System.out.println("Enter year");
               yearOfRelease=scaner.nextInt();
               scaner.nextLine();
               films[index]=new Film(filmName, director, yearOfRelease);

               break;
           case 2:  
               System.out.println("Enter film name");
               filmName=scaner.nextLine();
               System.out.println("Enter direcitor name");
               director=scaner.nextLine();
               System.out.println("Enter year");
               yearOfRelease=scaner.nextInt();
               scaner.nextLine();
               System.out.println("Enter language");
               language=scaner.nextLine();
               System.out.println("Enter tanslation");
               translation=scaner.nextLine();

               ForeignFilm foreignFilm=new ForeignFilm(filmName, director, yearOfRelease, language, translation);


               do
               {
                   System.out.println("Enter sub title");
                   subTitle=scaner.nextLine();
                   foreignFilm.addSubtitle(subTitle);

                   System.out.println("Add more y-yes,n-no");
                   ch=scaner.next().charAt(0);

               }while(ch!='n');


               //assign the object to the array of films at index
               films[index]=foreignFilm;

               break;
           case 3:  
               System.out.println("Enter film name");
               filmName=scaner.nextLine();
               System.out.println("Enter direcitor name");
               director=scaner.nextLine();
               System.out.println("Enter year");
               yearOfRelease=scaner.nextInt();
               scaner.nextLine();
               System.out.println("Enter language");
               language=scaner.nextLine();
               System.out.println("Enter tanslation");
               translation=scaner.nextLine();

               BollywoodFilm bollywoodFilm=new BollywoodFilm(filmName, director, yearOfRelease, language, translation);

               do
               {
                   System.out.println("Enter sub title");
                   subTitle=scaner.nextLine();
                   bollywoodFilm.addSubtitle(subTitle);

                   System.out.println("Add more y-yes,n-no");
                   ch=scaner.next().charAt(0);

               }while(ch!='n');

               do
               {
                   System.out.println("Enter second language");
                   secondLanguage=scaner.nextLine();
                   bollywoodFilm.addSecondLanguage(secondLanguage);

                   System.out.println("Add more y-yes,n-no");
                   ch=scaner.next().charAt(0);

               }while(ch!='n');


               do
               {
                   System.out.println("Enter song name");
                   song=scaner.nextLine();
                   bollywoodFilm.addSecondLanguage(song);

                   System.out.println("Add more y-yes,n-no");
                   ch=scaner.next().charAt(0);

               }while(ch!='n');
               //assign the object to the array of films at index
               films[index]=bollywoodFilm;              
               break;

           case 4:
               //print all moveis in the films array
               System.out.println("All Movie Details");
               for (int i = 0; i < index; i++)
               {
                   System.out.println(films[i]);
               }
               break;
           case 5:
               //terminate the program
               System.out.println("Program terminated");
               System.exit(0);

           }
          
          
           //increment the index value by oner
           index=index+1;

       }while(true);
       //cotinue the do while loop until user enters 5 to exit
   }

  
   //Method that promts user to enter choice
   private static int menu()
   {

       Scanner scaner=new Scanner(System.in);
       System.out.println("1.Film");
       System.out.println("2.Foreign Film");
       System.out.println("3.Bollywood Film");
       System.out.println("4.Print Movies");
       System.out.println("5.Exit");

       System.out.println("Enter your choice .");
       int choice=scaner.nextInt();

       return choice;

   }
}

------------------------------------------------------------------------------------------------------------------------------------------

Sample output:

1.Film
2.Foreign Film
3.Bollywood Film
4.Print Movies
5.Exit
Enter your choice .
2
Enter film name
Densha Otoko
Enter direcitor name
Shosuke Murakami
Enter year
2005
Enter language
Japanese
Enter tanslation
Train Man
Enter sub title
English
Add more y-yes,n-no
n
1.Film
2.Foreign Film
3.Bollywood Film
4.Print Movies
5.Exit
Enter your choice .
4
All Movie Details
Name of Film:Densha Otoko
Name of Director(s):Shosuke MurakamiYear of Release :2005
Language:Japanese
Subtitle Information:[English]Translation: Train Man
1.Film
2.Foreign Film
3.Bollywood Film
4.Print Movies
5.Exit
Enter your choice .

Hope this helps you