< Day Day Up > |
Let us look at the classes we have developed so far. Figure 7-1 gives the overall picture, and the listing in Example 7-1 gives the details. Example 7-1. Class details for the system so farclass CDRelease CommonString title UPCCode upc_code CDCategory category Days base_rental_period( ) Dollars get_rental_fee( ) class CDDisc CDRelease cd_release PhysicalID physical_id Rental current_rental start_rental(Customer the_renter) end_rental( ) // class PhysicalID class CDCategory class Rental Customer renter Timestamp start_time Timestamp end_time Days base_rental_period Boolean is_overdue( ) class CDDiscCollection CDDisc find_by_physical_id(PhysicalID a_physical_id) CDDisc [] find_by_cd_release(CDRelease a_cd_release) // Standard collection operations: add(CDDisc a_cd_disc) remove (CDDisc a_cd_disc) class CustomerID class Customer CustomerID customer_id CommonString name class CustomerCollection Customer find_by_customer_id(CustomerID a_customer_id) // Standard collection operations add(Customer customer_to_add) remove(Customer a_customer_id) // Check to see no current rentals We have two use cases that we are developing: Checkout_a_CDDisc and Checkin_a_CDDisc . Figure 7-2 gives an overall sequence diagram for the Checkout_a_CDDisc case. Figure 7-1. Class diagram for the system so farFigure 7-2. Checkout_a_CDDiscLikewise, Figure 7-3 gives a sequence diagram for the Checkin_a_CDDisc use case. Figure 7-3. Checkin_a_CDDiscFor those who prefer pseudocode to document the flow of use cases, the pseudocode for the Checkout_a_CDDisc use case is: CDDisc disc_being_rented = CDDiscCollection.find_by_physical_id(physical_id); Customer renter = CustomerCollection.find_by_customer_id(customer_id); disc_being_rented.start_rental(renter); And for the Checkin_a_CDDisc use case we have: CDDisc disc _rented = CDDisc.find_by_physical_id(physical_id); disc_rented.end_rental( ); The find_by... methods for the collections are straightforward, so details are not needed. For CDDisc , the pseudocode for the start_rental( ) and end_rental( ) methods looks like this: start_rental(Customer the_renter) { if (current_rental != NULL) signal CDDiscAlreadyRented; current_rental = new Rental(the_renter); produce_contract( ); } end_rental( ) { if (current_rental.is_overdue( )) perform_late_rental_procedure( ); current_rental = NULL; } We still have two operations that we have not examined in any detail: produce_contract( ) and perform_late_rental_procedure( ) . We look at those next . |
< Day Day Up > |