Java Reference
In-Depth Information
Sample
toString
Output
Ticket type
Description
Ticket
This is an abstract class representing all tickets
FixedPriceTicket
This is an abstract class representing tickets
that are always the same price. The constructor
accepts the price as the parameter.
ComplimentaryTicket
These tickets are free (thus FixedPrice ).
SN: 273, $0
WalkupTicket
These tickets are purchased on the day of the
event for $50 (thus FixedPrice ).
SN: 314, $50
AdvanceTicket
Tickets purchased ten or more days in advance
cost $30. Tickets purchased fewer than ten days
in advance cost $40.
SN: 612, $40
These are AdvanceTicket s that cost half of what
an AdvanceTicket would normally cost.
SN: 59, $15
(student)
StudentAdvanceTicket
c.
Implement the FixedPriceTicket 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 cor-
rectly with no code modification to the StudentAdvanceTicket class.
g.
Write a class TicketOrder that stores a collection of Ticket s. Tick-
etOrder 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.
 
Search WWH ::




Custom Search