Implement the ticket abstract class this class should store


Question: A set of classes is used to handle the different ticket types for a theater. All tickets have a unique serial number that is assigned when the ticket is constructed and a price. There are many types of tickets.

a. Design a class hierarchy that encompasses the above three classes.

b. Implement the Ticket abstract class. This class should store a serial number as its private data. Provide an appropriate abstract method to get the price of the ticket, provide a method that returns the serial number, and provide an implementation of toString that prints the serial number and price information. The Ticket class must provide a constructor to initialize the serial number. To do so, use the following strategy: maintain a static ArrayList representing previously assigned serial numbers. Repeatedly generate a new serial number using a random number generator until you obtain a serial number not already assigned.

2182_4.png

c. Implement the Fixed PriceTicket class. The constructor accepts a price. The class is abstract but you can and should implement the method that returns the price information.

d. Implement the WalkupTicket class and the ComplementaryTicket class.

e. Implement the AdvanceTicket class. Provide a constructor that takes a parameter indicating the number of days in advance that the ticket is being purchased. Recall that the number of days of advanced purchase affects the ticket price.

f. Implement the StudentAdvanceTicket class. Provide a constructor that takes a parameter indicating the number of days in advance that the ticket is being purchased. The toString method should include a notation that this is a student ticket. This ticket costs half of an Advanceticket. If the pricing scheme for AdvanceTicket changes, the StudentAdvanceTicket price should be computed correctly with no code modification to the StudentAdvanceTicket class.

g. Write a class TicketOrder that stores a collection of Tickets. TicketOrder should provide methods add, toString, and totalPrice. Provide a test program that creates a TicketOrder object and then calls add with all kinds of tickets. Print the order, including the total price.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Implement the ticket abstract class this class should store
Reference No:- TGS02457492

Now Priced at $15 (50% Discount)

Recommended (90%)

Rated (4.3/5)