Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction In this lab, you are introduced to multiple classes (a driver class and a data element class). You will write the driver class in

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Introduction In this lab, you are introduced to multiple classes (a driver class and a data element class). You will write the driver class in order to test the various methods provided in the data element class You are given a file called Movie.java, which has the data fields for a movie, along with "setters" and "getters", and a "toString" method. You will create a driver class from the pseudocode in Task #l below to test the Movie class. Follow the directions exactly, and in order. Task #1 writing a Driver Class 1. Create a new class called MovieDriver. In Eclipse, right-click on the project you created and select New->Class. In the wizard, name the class MovieDriver and check the box to create a main method. Open the file MovieDriver.java in Eclipse. Write Java code to implement the following p: 2. seudocode Create a new object of type Scanner that reads from the keyboard Create a new movie object Prompt the user to enter the title of a movie Read in the line that the user types Set the title in the movie obiect Prompt the user to enter the movie's rating Read in the line that the user types Set the rating in the movie object Prompt the user to enter the number of tickets sold at a (unnamed) theater Read in the integer that the user types Set the number of tickets sold in the movie object Print out the information using the movie's toString method 3. 4. Run your driver class to be sure it prints out the information you type in Your Eclipse console should look something like this: Problems@ Javadoc Search ConsoleDebug MovieDriver (1) [Java Application] CAProgram FilesJavaljdk18. Enter the name of a movie Concussion Enter the rating of the movie PG13 Enter the number of tickets sold for this movie 4321 Concussion (PG13): Tickets Sold: 4321 Do you want to enter another? (y or n) Enter the name of a movie The Good Dinosaur Enter the rating of the movie PG Enter the number of tickets sold for this movie 5432 The Good Dinosaur (PG) Tickets Sold: 5432 Do you want to enter another? (y or n) oodbye 5. HINT: if vour program ends before reading your keyboard input, vou may have not read the previous line feed, so when you read a line expecting it to be the next line of input, it is instead just the previous "n". To solve this problem, you may be able to put in an additional in.nextLine0; just to read and discard the line feed. Turn in the following: files; submit the java MovieDriver.Java from Task #2 and Movie-Java (NOT the .class files). Submit both files, even though you have not changed Movie.java. Code Listing 3.1-Movie.java public class Movie private String title private String rating private int sold ickets title = "" rating = ""; soldTickets 0; public Movie (Movie m) title m.title; rating m.rating; soldTickets- m.soldTickets public Movie(String title, String rating, int soldTickets) this title title this.rating rating this.sodickets soldlickets public Stringgetitel) return title public void setTitle(String title) this,title- title public String getRating() return rating public void setRating(String rating) this.rating = rating public int getSoldTickets() f return soldTickets public void setSoldTickets(int soldTickets) this,soldTickets soldTickets public String toString) return (this title+" ("this rating+"): Tickets Sold: "+this,soldTickets)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory Icdt 97 6th International Conference Delphi Greece January 8 10 1997 Proceedings Lncs 1186

Authors: Foto N. Afrati ,Phokion G. Kolaitis

1st Edition

3540622225, 978-3540622222

More Books

Students also viewed these Databases questions