Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is code for movie, theatre, patron and ticket classes public class Movie { String title; double earnings; //initializing movie object public Movie(String title){ this.title

image text in transcribedimage text in transcribedimage text in transcribed

Here is code for movie, theatre, patron and ticket classes

public class Movie { String title; double earnings; //initializing movie object public Movie(String title){ this.title = title; earnings = 0; } //getters and setters public String getTitle(){ return title; } public void setTitle(String title){ this.title = title; } public double getEarnings(){ return earnings; } public void setEarnings(double earnings) { this.earnings = earnings; } } 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

public class Theatre { Movie moviePlaying; int capacity; int seatsSold; // Constructor to initialize a Theatre object public Theatre(int capacity){ this.capacity = capacity; seatsSold=0; } //getters and setters public Movie getMoviePlaying() { return moviePlaying; } public void setMoviePlaying(Movie moviePlaying) { this.moviePlaying = moviePlaying; } public int getCapacity() { return capacity; } public void setCapacity(int capacity) { this.capacity = capacity; } public int getSeatsSold() { return seatsSold; } public void setSeatsSold(int seatsSold) { this.seatsSold = seatsSold; } } 

//////////////////////////////////////////////////////////////////////////////

public class Patron { int age; Ticket ticket; //Initializing a Patron public Patron(int age){ this.age = age; } //getters and setters public int getAge(){ return age; } public void setAge(int age){ this.age = age; } public Ticket getTicket() { return ticket; } public void setTicket(Ticket ticket){ this.ticket = ticket; } } 

///////////////////////////////////////////////////////////////////////////////////

public class Ticket{ Theatre theatre; //Initializing a Ticket public Ticket(Theatre theatre){ this.theatre = theatre; } //getters and setters public Theatre getTheatre(){ return theatre; } public void setTheatre(Theatre theatre){ this.theatre = theatre; } } 

Define a class called BoxOffice that keeps track of two theatres for which it sells movie tickets. The cost of a movie ticket is $6.25 for children under 12 years old, $5.75 for adults 65 years old or more and $12.50 for everyone else. The box office should also keep track of the movie that has made the most money in the past. Carefully examine the test program below. Understand how it is supposed to work. Then write the necessary methods so that the code runs properly, producing the correct results. You may NOT alter the test programthe TA will be using it to test you patrons, the title of the movie is provided. You will need to determine which theatre that movie is playing in. As a hint, you can compare two strings using the .equals() method in JAVA as follows r code. Note that when tickets are sold to String s1 = ; String s2 = ; if (si.equals (s2)) else Note as well in the program below that the bestMovie() will either be a previous movie that had the whichever has the most earnings most earnings or one of the current playing movies Here is the test program public class BoxofficeTestProgram public static void main (String args) // Create a box office with two theatres, each with a capacity of 5 seats BoxOffice box = new BoxOffice (5, 5); /Open up a couple of new movies at the box office System.out.println ("Theatre A opens movie: Justice League") box.openMovie ("Justice League", box.theatreA) System.out.println("Theatre B opens movie: Geostorm") box. openMovie ( "Geos torn". box. theatreB) ; 7Now create some patrons Patron pl, p2, p3, p4, p5, p6, p7, p8, p9, p10, pll, p12: p1 = new Patron (15); p2new Patron (26): p3 new Patron (7); p4 new Patron (72); p5 = new Patron (65); p6 = new Patron ( 1 1 ) ; p7 new Patron (19); p8 # new Patron ( 1 7 ) ; p9 -new Patron (12); p10 new Patron ( 14); p11 = new Patron ( 13); p12 new Patron (16): ...continued on the next pageI/

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_2

Step: 3

blur-text-image_3

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

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions

Question

_________ is the consistency of a test measurement.

Answered: 1 week ago