Thursday, October 22, 2009

Lab 16

Define a Class named Product whose objects are records for a department. A Product has the id number (use type String). Define a Class named Book. Derive this class from Product. You can define the attributes of Book. For example, A Book object has the id (defined in Product class), the book name (use type String) and the price (use type double). Define another Class named Shirt. Derive this class from Product. Define the attributes of Shirt. For example, A Shirt object has the id (defined in Product class), the color (use type String), and the size (use type String). Give your classes a reasonable complement of constructions and accessor methods, and a toString() methods which can display the infomation of product in the cart.

Define a Class named Cart whose objects are records for customer. A customer has the contents which is the array of Product in the cart. Give your classes a reasonable complement of constructions and accessor methods, a add mothods with product object as parameter which can add the product to your cart (the array of product), and a toString() methods which can display the infomation of all product in the cart

No comments: