Question: // Assignment #: 4 // Name: Your name // StudentID: // Lecture: // Description: Assignment 4 class displays a menu of choices to a user

 // Assignment #: 4 // Name: Your name // StudentID: //

// Assignment #: 4 // Name: Your name // StudentID: // Lecture: // Description: Assignment 4 class displays a menu of choices to a user // and performs the chosen task. It will keep asking a user to // enter the next choice until the choice of 'Q' (Quit) is entered. import java.util.*; public class Assignment4 { public static void main (String[] args) { // local variables, can be accessed anywhere from the main method char input1 = 'Z'; String inputInfo; String title, yearStr, lengthStr, prodName, prodCity, prodState; int year, length; String line = new String(); // instantiate a Movie object Movie movie1 = new Movie(); printMenu(); //Create a Scanner object to read user input Scanner scan = new Scanner(System.in); do // will ask for user input { System.out.println("What action would you like to perform?"); line = scan.nextLine(); if (line.length() == 1) { input1 = line.charAt(0); input1 = Character.toUpperCase(input1); // matches one of the case statement switch (input1) { case 'A': //Add Movie System.out.print("Please enter the Movie information: "); System.out.print("Enter its title: "); title = scan.nextLine(); movie1.setMovieTitle(title); System.out.print("Enter its length: "); lengthStr = scan.nextLine(); length = Integer.parseInt(lengthStr); movie1.setLength(length); System.out.print("Enter its year: "); yearStr = scan.nextLine(); year = Integer.parseInt(yearStr); movie1.setYear(year); System.out.print("Enter its production company name: "); prodName = scan.nextLine(); System.out.print("Enter its production company's city: "); prodCity = scan.nextLine(); System.out.print("Enter its production company's state: "); prodState = scan.nextLine(); movie1.setProdCompany(prodName, prodCity, prodState); break; case 'D': //Display Movie System.out.print(movie1); break; case 'Q': //Quit break; case '?': //Display Menu printMenu(); break; default: System.out.print("Unknown action "); break; } } else { System.out.print("Unknown action "); } } while (input1 != 'Q' || line.length() != 1); } /** The method printMenu displays the menu to a user **/ public static void printMenu() { System.out.print("Choice Action " + "------ ------ " + "A Add Movie " + "D Display Movie " + "Q Quit " + "? Display Help "); } }

Assignment #4 will be the construction of 2 new classes and a driver program the class containing a main method). Production class The Production class describes information of a production company. It has following attributes: ute Attribute name Description vpe String String companyName name or the product company state o locationState The following constructor should be provided to initialize each attribute. This constructor initializes the value of string attributes to "?" public Production) The following accessor methods should be provided to get the attributes: public String getCompanyName(0 public String getLocationCity0 The following modifier(mutator) methods should be provided to set the attributes: public void setCompanyName(String someName) public void setLocationCity (String someCity) public void setLocationState(String someState) The following method must be defined: publie String toString0 toString method should return a string of the following format MGMat Holhwood CA where "MGM is a company name, "Hollywood" is its city name, and "CA" is its state. So you need to insert" or a string between these variables. Note that you can choose a meaningful parameter variable name for each method. Movie class The Movie class describes a movie. It has the following attributes: Attribute name Description vpe mowielitle ar o movie nt uction c movie The following constructor should be provided to initialize each attribute. This constructor initializes the value of string attributes to "?" and the value of integer attribute to 0, and an object of Production using the constructor of the Production class. public Movie) The following accessor methods should be provided to get the attributes: public String getMMovieTitle0 public int getYear0 public intg public Production g The following modifier(mutator) methods should be provided to change the attributes: public void setMovieTitle (String someTitle) public void setYear(int someYear) public void setLength int someLength) public void setProdCompany(String someName, String someCity, String someState) The following method must be defined: public String toStringO The toString method constructs a string of the following format: nMovie TitleTov StoryIn Movie Length:rt8ln Movie Year:1995n Movie Production: tPixar Animation at Emenville,CAnn Assignment4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!