These 3 Classes (PreferredCustomerBill and NewCustomerBill and Item) reside in a separate "billing" folder in your "shopping" folder which is package "shopping.billing" thus enforcing protected access, as Tester.java will be run from a different (default) package. *PreferredCustomerBill has a constructor that allows a preferred customer object to be constructed from a former NewCustomer object. *Preferred customers can add as many Items as they please. *Preferred customers always get the discount, so you have a getTotal() over-ride. *Preferred customers need a different toString() to display TOTAL correctly. *Preferred customers implements the remove(Item) method, but new customers cannot Data fields listed at top of Class, and they are all private. Fields are not initialized in these private declarations (Java defaults prevail). Only exception to above are public static final constants, which never change. Constructors (that's plural) follow the data field specifications, and those initialize all the fields. Always have a default constructor that defines the assumed defaults for all fields (verify if needed). No redundant constructor code, so the multiple argument version is used for others with this() calls. No redundant method code, so a detailed math formula is in one place, then used by others. Accessor methods are grouped together. Mutators grouped together. No random placements in Class.
Get Free Quote!
324 Experts Online