203k views
0 votes
Scenario

You have been hired to help a company with their product ordering system. They sell many products online to a variety of customers and need to produce packing labels, shipping labels, and compute final prices for billing.

Program Specification

Write a program that has classes for Product, Customer, Address, and Order. The responsibilities of these classes are as follows:

Order

Contains a list of products and a customer. Can calculate the total cost of the order, and can return a string for the packing label, and can return a string for the shipping label.

The total price is calculated as the sum of the prices of each product plus a one-time shipping cost.

This company is based in the USA. If the customer lives in the USA, then the shipping cost is $5. If the customer does not live in the USA, then the shipping cost is $35.

A packing label should list the name and product id of each product in the order.

A shipping label should list the name and address of the customer

Product

Contains the name, product id, price, and quantity of each product.

The price of this product is computed by multiplying the price and the quantity.

Customer

The customer contains a name and an address.

The name is a string, but the Address is a class.

The customer should have a method that can return whether they live in the USA or not. (Hint this should call a method on the address to find this.)

Address

The address contains a string for the street address, the city, state/province, and country.

The address should have a method that can return whether it is in the USA or not.

The address should have a method to return a string all of its fields together in one string (with newline characters where appropriate)

Other considerations

Make sure that all member variables are private and getters, setters, and constructors are created as needed.
Once you have created these classes, write a program that creates at least two orders with a 2-3 products each. Call the methods to get the packing label, the shipping label, and the total price of the order, and display the results of these methods.

User Igor Mizak
by
8.8k points

1 Answer

4 votes

Final answer:

The task is to design an object-oriented program for a product ordering system with classes for Product, Customer, Address, and Order, which calculate costs and generate labels.

Step-by-step explanation:

The question pertains to the design of an object-oriented program in a product ordering system. The classes Product, Customer, Address, and Order are to be created with specific responsibilities and attributes. Orders calculate the total cost and produce packing and shipping labels; Products hold information about items; Customers have names and addresses, and can determine if they live in the USA; Addresses store location details and can identify if they are in the USA.

For a program that computes the final price, includes shipping, and assembles appropriate labels, one must consider class responsibilities and data encapsulation. The shipping cost varies based on the customer's location (domestic or international). The packing label should include product details, while the shipping label should feature customer address details.

Once the classes are defined, instances of orders, with included products, and associated customers are to be created to demonstrate the program's functionality by displaying total prices and labels.

User Jeremy Kemball
by
8.4k points