The purpose of this exercise is to model the types of tickets that might be sold for
Question:
The purpose of this exercise is to model the types of tickets that might be sold for campus events. All tickets will have Strings for the venue, event name, and date. Each ticket will also have a base price. Create an abstract class Ticket with the following constructor: public Ticket(String venue, String event, String date, double basePrice) provide getters for the venue, event, date, and basePrice provide a method int getNumberOfHolders() that returns 1. provide a toString method provide an abstract method to return the actual cost of this transaction double getPrice() Create a subclass AdvanceTicket for tickets bought in advance at a discount. The constructor for AdvanceTicket should be public AdvanceTicket(String venue, String event, String date, double basePrice, double discount). Thediscountvalue is a ratio for reducing thebasePriceof the ticket.
Create a subclass ComplementaryTicket for tickets given away for free. The constructor for ComplementaryTicket should be public ComplementaryTicket(String venue, String event, String date) Create a subclass DayOfTicket for tickets purchased the day of the event for full price. The constructor for DayOfTicket should be public DayOfTicket(String venue, String event, String date, double basePrice) Create a subclass GroupTicket for multiple tickets purchased together at a discount. The constructor for GroupTicket should be public GroupTicket(String venue, String event, String date, double basePrice, double discount, int quantity) The discount value is a ratio for reducing the basePriceof each ticket, and quantity is the number of tickets for the group. The number of holders for a group ticket is the number of people in the group. You will need to supply additional instance variables, methods, and overridden methods as appropriate. Do as much of this as necessary, but no more. (And don't forget toString.)
Hint: For some classes, you may be able to save some work by extending a class other than Ticket.
Grading Elements:
- all classes are in the appropriate packages
- all classes have the specified constructors and methods with correct signatures
- ticket prices are calculated correctly
- subclasses exploit Ticket as much as possible
- subclasses do not shadow (duplicate)Ticket instance variables or needlessly override methods
- subclass-specific behavior is implemented as overriding methods
Data Modeling and Database Design
ISBN: 978-1285085258
2nd edition
Authors: Narayan S. Umanath, Richard W. Scammel