Question: JAVA Object Classes: designing Shopping Cart Shopping Cart , build a checkout system for a shop which sells items (i.e., products say Bread, Milk, and

JAVA

Object Classes: designing Shopping Cart

Shopping Cart , build a checkout system for a shop which sells items (i.e., products say Bread, Milk, and Bananas). A shopping cart that can have multiples. Costs of the products are : Bread - $1, Milk - $0.60 and Banana - $0.40. A system should displays the order total.

The heart of a shopping cart can be represented in three classes: a cart class an order class, and an item class. Item objects are added to an array stored within the cart object.

Object Classes: designing Shopping Cart

JAVA Object Classes: designing Shopping Cart Shopping Cart , build a checkout

Object Classes: designing Shopping Cart

Think first what are the nouns in the specification? (ex: Item) These are likely your Objects or possibly key data in an object

Which responsibilities belong to which nouns? These are likely to become their methods.

What are the relationships between nouns (Objects)? Draw it out that will help you visualize how they are interconnected

Object Classes: designing Shopping Cart

You will find that several Objects have a Has-a relationship An ItemOrder has an Item (one to one relationship) A ShoppingCart has many ItemOrders (one to many relationship)

system for a shop which sells items (i.e., products say Bread, Milk,

Object Classes: designing Shopping Cart

and Bananas). A shopping cart that can have multiples. Costs of the

Summary Methods with same name, different signatures are overloaded methods An enumeration is a class can have instance variables, constructors, methods A package of class definitions grouped together in same folder, contain a package statement at beginning of each class

Item i double price ItemOrder io 2 int quantity String name 42 "String cheese

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!