Create suitable subclasses

Assignment Help JAVA Programming
Reference no: EM131587108

Programming: Assignment

Place all Java source code.

The goal of this assignment is to create a movie booking system that allows a teller to book Adult, Elderly or Child tickets to different movies using a nicely presented front end GUI. It should keep track of different movies being played, which seats have already been booked and not allow child tickets to be purchased for R rated movies or ensure that a child has to be accompanied by an adult for M rated movies.

Question 1) : Time Class
Using the UML below, create a class that encapsulates integers used to represent hours, minutes and seconds for the time of day in 24 hour format.
- It has four constructors, each passing in different ways a Time object can be created (use a value of 0 for variables not set during construction).
- The class also has getters and setters for each of these fields.
- The Time class should ensure that variables cannot be set below zero or some other invalid value eg: minutes and seconds should only be between 0-59, hours 0-23.
- Create a suitable toString method that prints the time as double digit format. Eg 10:30 pm should return "22:30:00" whereas 12:05 am should return the format "00:05:00".
- Override the equals method of Object so that two Time objects are considered equal if both have hours, minutes and seconds the same.
- The class should also implement the Comparable interface comparing other times so that the earlier time takes precedence. Eg, if this current Time object is earlier in the day than the parameter object then a negative number should be returned.

Question 2) SeatReservation
Prepare an abstract class called SeatReservation for describing an abstract seat booking. It has an abstract method getTicketPrice intended to be overridden by subclasses. It holds a row (char) and column (int) of where the seat is positioned in the movie theatre and a boolean to indicate whether the seat is complementary (free). Create the class following the UML below.

Question 3) SeatReservation subclasses
Create suitable subclasses of SeatReservation called AdultReservation, ChildReservation and ElderlyReservation for allowing the seat to be filled by a child, adult or elderly person. A child class should return the ticket price of $8, whereas an adult ticket should return the ticket price of $12.50. An elderly ticket should return the price which is always %30 off the adult ticket price. However if any of the tickets are complementary, then the price is zero.

Question 4) MovieSession
Using the UML below, create a class called MovieSession which represents a movie with a name, a rating (R, M or G) and a screening time (using the Time class from question 1).
- It also holds a two dimensional array of SeatReservation references called sessionSeats, with null entries indicating that the seat is available otherwise it points to either a valid ElderlyReservation, ChildReservation or AdultReservation depending on the row and col value (where an ‘A' represents an index 0, ‘B' index 1 ect).
- The class also has two static constants used for obtaining the dimensions of the sessionSeats
array.
- It should have suitable getters for obtaining movie information and a suitable toString which prints out the movie name, the rating and the session time.
- The class implements the Comparable interface comparing session times between the two MovieSession instances where an earlier session time should take precedence. If the session time is the same between the two, then use the movie name as a comparison.
- It has two static methods, convertRowToIndex and convertIndexToRow used to convert row letters to an index so that a row and col can be used to refer to the two dimensional array of sessionSeats.

- The isSeatAvailable should return a true if a seat at the specified row and column has not been previously booked (ie is null).
- A getSeat returns the SeatReservation object held at a specific row and column (could be null, if not booked).
- An applyBookings method takes a List of SeatReservations, this method needs to look through the reservations one by one and ensure that the designated row and col is available in the two dimensional array of sessionSeats (ie not previously booked), otherwise the booking for those seats won't be made and the method will return false. It also needs to ensure that a child reservation cannot be booked in an R rated movie and a child reservation can only be made for an M rated movie if accompanied by an adult. If these conditions are not met then the booking for those seats won't be made and the method will return false. Otherwise if the condition is met and the seats are available the method then needs to apply the bookings. It does this by assigning each of the reservations held in the parameter list to the sessionSeats array matching their row and column values.
- It also has a printSeats method which prints out the sessionSeats array with an underline if empty, E for elderly, C for child and A for adult.
- Example for a 5x3 seating arrangement in G rated movie :
|_||A||_||_||_|
|_||A||E||C||_|
|_||A||_||C||C|

Question 5) Simple Driver
Create a suitable main method inside MovieSession which creates an ArrayList of different movie sessions with different times and ratings. Use the java.util.Collections class to sort the movies in order (this will test out whether your compareTo is correct in question 4.
For each of the movies try applying some bookings both when the seats are free and if the seats are taken, also try combinations of trying to book child tickets to both R and M rated movies both with and without an adult.

Question 6) MovieBookingGUI
Create a front end GUI called MovieBookingGUI for booking movies. It should be a subclass of JPanel and hold many different GUI components. It also will be used to listen for JButton and JList events. It also has the following features:
- A main method which creates an ArrayList of MovieSessions and sorts them using the Collections class, it then passes this to the MovieBookingGUI constructor during instantiation. It then creates a JFrame and adds the MovieBookingGUI object instance to it.
- The GUI should have JRadioButtons for selecting child, adult or elderly bookings and a
JCheckBox for declaring whether the booking is complementary
- The GUI should have a JList with a DefaultListModel for holding MovieSession objects which were passed in to the constructor with the currently displayed MovieSession selected. The list needs to listen for events.
- It should hold an ArrayList<SeatReservation> field called currentReservation which highlights seats as they are being selected. This holds the corresponding SeatReservations temporarily when selecting seats. This should be cleared once booked (by passing it into the applyBookings method of the currently displayed MovieSession), and cleared if the booking was cancelled or if a different MovieSession is selected in the JList.
- It should display a 2 dimensional array of JButtons called seatingButtons which represent seats in the theatre displaying corresponding row and column values as text inside each button. When selecting seats they become highlighted (by changing their foreground colour. YELLOW for child, WHITE for elderly or BLUE for adult) and added to the currentReservation list depending on whether an adult, child or elderly is being booked.
- The two dimensional array of buttons should be enabled if the seat is available. If a seat is taken then it should be disabled and have its background colour set to YELLOW for child, WHITE for elderly or BLUE for adult to indicate which reservation type is sitting in that seat.
- HINT: may want a helper method which enables/disables seating buttons and sets their background colour depending on which subclass of SeatReservation has filled the seat. This should be called whenever the currently displayed movie is changed, the bookings have been completed or cancelled.
- It should contain another JButton which cancels the current booking session, a JButton to exit the GUI and a JButton which tries to book the currentReservation inside the currently selected MovieSession calling its applyBookings method.
- If the applyBooking returns a false display a dialog telling the user that there was a mistake in the booking process (as perhaps seat has been filled or trying to book a child in an adult movie). Otherwise if successful then display a dialog box showing the number of tickets

booked and the total cost of the tickets. The currentReservation list then needs to be cleared ready for the next customer to book tickets.
- Plan out the GUI and think what extra JPanels are needed, what components they will hold and how they should be laid out with an appropriate LayoutManager.
- Bonus marks given for a good job with layout, handing unexpected user inputs and fully working functionality.

Here is a screenshot with B1-B4 already booked with 2 adult and elderly and a child. The user has tried to book D0 and D1 as child tickets, but need an adult with M-rated movie: Second screen shot shows that it now works and has been successfully booked as children are now accompanied with an elderly adult. The 3rd screenshot reflects these changes with the updated seatingButtons.

Reference no: EM131587108

Questions Cloud

Describe the credentialing issues in this case : . Discuss what steps a hospital should take to help ensure that a physician is competent to perform the procedures he or she is requesting.
How many sets of four balls contain at least one teal ball : Does there exist a planar graph with five vertices, ten edges, and seven faces?
What is the amount of jason : Jason and Mary are married taxpayers in 2013. They are both under age 65 and in good health. What is the amount of Jason and Mary's adjusted gross income
How many ways are there to deal a standard deck of cards : Let connected simple G have vertices of degrees 4,4,4,5,5,5,6,6,6,7,7,7. Prove that G is non-planar.
Create suitable subclasses : Create suitable subclasses of SeatReservation called AdultReservation, ChildReservation and ElderlyReservation - Create a suitable main method inside MovieSessi
Advantages and disadvantages of standard costs : What are some of the advantages and disadvantages of standard costs? How do managers determine what the standard cost should be
History and status quo in country or sovereignty : The Presentation will be the crafting of a policy or law based on one of the subjects we have learned for a country other than the United States of America.
How many yes-or-no questions does rania need to ask reza : Reza and Rania play a guessing game. Reza picks a whole number in the 0-15 range.
Conduct research to locate the vision and mission statements : Conduct research to locate the vision and mission statements for a law enforcement or correctional organization upon which to base your initial post.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program that simulates a simple calculator

Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a +, the sum is printed; if it is a -, the difference is printed; if it is a *, the product is printed; if it is a /, the quotient is pr..

  Define a subclass of tournaments called collegegames

Define a subclass of Tournaments called CollegeGames. The subclass should include an additional member having type String and visibility public.

  Modify the book class to accommodate multiple authors

modify the Book class to accommodate multiple authors using one of the components from the Java Collection Framework.

  Create servlet that display form when doget method is invoke

Create a Servlet that displays a form when the doGet method is invoked. The form will contain a post action that directs the form post back to the same servlet, which in doPost method will append the form data to a random access file.

  Discuss what kind of tactics you should use to achieve that

Draw a sequence diagram for this system. Suppose that we want greater availability of the server, discuss what kind of tactics you should use to achieve that.

  Create a login form

In this week's lab, we will create a login form, validate a user based on their login name and password, and allow them to access the system or not

  How many tickets for each class of seats were sold

Prepare a program that asks how many tickets for each class of seats were sold, then shows the amount of income generated from ticket sales.

  Define responsive design

Define Responsive Design and clarify what techniques can be used to create a responsive design for a web application? Explain what makes jQuery Mobile different from other JavaScript libraries such as jQuery and jQueryUI

  Create a simple java program that connects to database

create a simple Java program that connects to this database using JDBC. Your program should then query this database's "student" table.

  Write a java program called numbers

Methods Lab   1. Write a Java program called Numbers that calls the following methods and displays the returned value: o Write a method called cubeIt that accepts one integer parameter and returns the value raised to the third power as an integer.

  Collection of scores (type int) for the last exam i

After being given a collection of scores (type int) for the last exam in your computer course, you are to computer the average of the scores and assign grades (O, S, U i.e. Outstanding, Satisfactory, Unsatisfactory)) to each student according to the ..

  Write a fraction class called fraction.java

Write a Fraction class called Fraction.java that implements these methods: add - This method receives a Fraction parameter and adds the parameter fraction to the calling object fraction. multiply - This method receives a Fraction parameter and multip..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd