Question: Topics This assignment will give you practice with classes, inheritance, arrays, and thinking/designing code with an Object-Oriented approach. Instructions You are going to write a
Topics
This assignment will give you practice with classes, inheritance, arrays, and thinking/designing code with an Object-Oriented approach.
Instructions
You are going to write a program that will simulate the very beginnings of a Ticketing System for an entertainment venue (think Key Arena, Tacoma Dome, Quest Field, etc). You will design a Ticket class and a VIPTicket. You will then write a main program that will create a set number of Tickets and print out an ascii art version of the tickets.
In theory, we could continue to build on this program to create a more complicated system that allows people to purchase tickets (become owners of tickets), calculate sales, and much more like TicketMaster or StubHub.
Ticket Class
You need to write a Ticket class, where:
A ticket has a the following state fields: seat number, cost, and owner.
The Ticket class should also share a class variables with all Tickets for the next available seat (this changes every time a ticket is issued).
A Ticket should be able to be created given no information. Only a constructor with no parameters needs to be defined.
Tickets should be created starting with seat #1, and every subsequent ticket should be one seat higher.
Tickets should cost $10 by default.
You determine what the starting value of the owner field is.
A Ticket should have accessors for all fields.
A Ticket should have mutators for only the owner. (You cannot change the price of a ticket after creation, nor the seat number assigned to a ticket.)
A Ticket should have a getType method which returns a String that returns "General Admission" as the ticket type.
A Ticket should have a discounts method which returns a String that indicates that Tickets (regular tickets) have no associated discounts. Other types of tickets will have discounts and you will override this method.
A Ticket should have a toString method which can be used to print a ticket. You determine how a ticket should print.
Tester Code
After you create (or as you create) your Ticket class, you should write tester code to make sure that your Ticket performs as expected. You will need to turn this code in. In this file, everything can be done in the main - it just needs to appropriately test all the functionality of your Ticket class by creating a Ticket object and then calling various methods on it.
VIPTicket
Create a VIPTicket class which is a subclass of Ticket. VIPTickets have mostly the same state and behavior of a Ticket, except:
A VIPTicket should be able to be created given no information. Only a constructor with no parameters needs to be defined.
This constructor should appropriate initialize all of the inherited fields from the Ticket superclass.
A VIPTicket should cost three times the cost of a general Ticket.
A VIPTicket should have a type of "VIP"
A VIPTicket should receive a discount of Free Parking.
You should add some testing code to your tester file to test that objects of this type work as expected.
Ticket Client
You should create a Client program to create tickets and then print those tickets.
This class should contain a main method and should declare an array of Tickets.
The number of tickets created should be a class constant at the top of the program so that it can be easily changed.
You should have a method that takes the Ticket array as a parameter and create new Tickets according to the following:
95% of the total tickets should be general admissions tickets (Ticket objects)
5% of the total tickets should be VIP tickets (VIPTicket objects)
Make sure that the total number of tickets adds up to the constant at the top of the program! Do not hardcore in the amounts for each type of ticket - come up with a formula using the class constant.
You should have a method that takes the Ticket array as a parameter and prints all the tickets by utilizing the methods in the Ticket/VIPTicket classes. YOUR PRINTED TICKET SHOULD NOT LOOK EXACTLY LIKE MINE!
Your printed tickets must print: the seat, the cost, the type of ticket, and any ticket's associated discounts.
Sample Output
T|========================== I| SEAT # 1 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 2 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 3 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 4 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 5 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 6 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 7 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 8 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 9 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 10 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 11 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 12 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 13 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 14 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 15 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 16 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 17 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 18 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 19 C| COST: $10.00 K| TYPE: General Admissions E| No associated discounts T|========================== T|========================== I| SEAT # 20 C| COST: $20.00 K| TYPE: VIP E| You get FREE Parking! T|==========================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
