public class SalesLineltem private int quantity private Product specification product Spec Productspecification SalesLineltem description: Text quantity: Integer Described-bt price: Money productSpec itemID: ItemID get Subtotal(: Money Role name used in attribute name Figure 20. 4 Role names may be used to generate instance variable names
Sale public class Sale date: Date private Date date Time= new Date…}…… is Complete: Boolean time: Time become ompleteO makeLineltemo makePaymentO In Java, the java util. Date class combines both date arpd l getTtotalo timestamp information. Therefore, the separate attributes in the design can be collapsed when mapping Figure 20.5 Mapping date and time to Java
ProductSpecification spec catalog get Specification(id) ale. makeLineltem(spec, gty) enterltem(id, qty+ 2: makeLineltem(spec, gtyt e Registe Sale 1: spec: get Specification(id Produc Figure 20.8 The enterltem method
Sale public class Sale date: Date is Complete: Boolean SalesLineltem time: Time Contains private List lineltems =new Array List O quantity: Integer become Complete make Lineltemo I getSubtotalO make Payment( getT total A collection class is necessary to\. maintain attribute vis ibility to all the SalesLineltems Figure 20. Adding a collection
●实现的顺序
实现的顺序