Skip to main content

Adding Order Processing Classes

We are going to define two new classes: a TicketOrder class, with information for each order; and a TicketItem class, with information for each show for which tickets are ordered. This design enables an order to contain tickets for multiple films—perhaps the parents want to see one film and the children of the family some other film showing at about the same time. (If we didn't need this flexibility, we could just store the item information in the TicketOrder class.)

generated description: newticketorderclassdiagram.jpg

The TicketOrder class contains an Items property that is a list of references to TicketItem objects, a Total property (of type %FloatOpens in a new tab) that is the total cost of the order, and a Complete property (of type %BooleanOpens in a new tab) that indicates whether or not this order is “complete”. The Complete property is initially set to 0 (false); when the order is completed, we will set this flag to 1 (true).

generated description: newticketitemclassdiagram.jpg

The TicketItem class contains AdultTicket and ChildTickets properties that store the number of tickets purchased, a TicketOrder property that refers back to the associated TicketOrder object, and a Show property that refers to the Show object for which the tickets were purchased.

FeedbackOpens in a new tab