hello I am suppose to do this assignment can someone help me.
Shopping Cart
In this assignment, you will write an application to print receipts for purchases made at a store. The project consists of three classes:
1. The Item class represents an item that is for sale. An Item has a number, a name, and a price. For instance:
123, T-Shirt, $15.99
2. The Purchase class represents a customer's purchase of one or more Items. Each Purchase has a date, a subtotal, tax, and a number of items.
3. A driver class.
The UML class diagrams for Item and Purchase are shown here:
Item
- num
- name
- price
_______________ _
+ Item(num, name, price)
+ getNum
+ setName
+ getName
+ setPrice
+ getPrice
+ toString
Purchase
- Item[] items
- Date date
- subtotal
- tax
- numItems
+ TAX_RATE
- MAX_ITEMS
_______________ _
+ Purchase()
+ add(Item)
+ getSubtotal()
+ getTax()
+ total()
+ printReceipt()
In the Purchase class, initialize TAX_RATE to 0.086, and MAX_ITEMS to 100 in a static block. Then, write the methods shown in the diagram:
Purchase() Allocates memory for the items array to MAX_ITEMS
Initializes date to the current date
date = new Date();
Initializes subtotal, tax, total and numItems to zero
add(Item item): Checks to see if MAX_ITEMS is reached. If so, prints “Array is full.” Otherwise: Add new item to array at position numItems
Increment numItems
Adjust the subtotal to include the price of the new item
Adjust the tax to include the tax on the new item
getSubtotal(): returns subtotal
getTax(): returns tax
total(): returns total (subtotal plus tax)
printReceipt(): prints a summary of the purchase, including: “SALES RECEIPT"
date of purchase
a list of purchases, including item numbers, names and prices
the subtotal, tax, and total for the purchase, all formatted as currency.
write a driver class that contains a main method.
Instantiate at least three new items.
Create a new purchase
Add several items to the purchase
Print a receipt
Shopping Cart
In this assignment, you will write an application to print receipts for purchases made at a store. The project consists of three classes:
1. The Item class represents an item that is for sale. An Item has a number, a name, and a price. For instance:
123, T-Shirt, $15.99
2. The Purchase class represents a customer's purchase of one or more Items. Each Purchase has a date, a subtotal, tax, and a number of items.
3. A driver class.
The UML class diagrams for Item and Purchase are shown here:
Item
- num
- name
- price
_______________ _
+ Item(num, name, price)
+ getNum
+ setName
+ getName
+ setPrice
+ getPrice
+ toString
Purchase
- Item[] items
- Date date
- subtotal
- tax
- numItems
+ TAX_RATE
- MAX_ITEMS
_______________ _
+ Purchase()
+ add(Item)
+ getSubtotal()
+ getTax()
+ total()
+ printReceipt()
In the Purchase class, initialize TAX_RATE to 0.086, and MAX_ITEMS to 100 in a static block. Then, write the methods shown in the diagram:
Purchase() Allocates memory for the items array to MAX_ITEMS
Initializes date to the current date
date = new Date();
Initializes subtotal, tax, total and numItems to zero
add(Item item): Checks to see if MAX_ITEMS is reached. If so, prints “Array is full.” Otherwise: Add new item to array at position numItems
Increment numItems
Adjust the subtotal to include the price of the new item
Adjust the tax to include the tax on the new item
getSubtotal(): returns subtotal
getTax(): returns tax
total(): returns total (subtotal plus tax)
printReceipt(): prints a summary of the purchase, including: “SALES RECEIPT"
date of purchase
a list of purchases, including item numbers, names and prices
the subtotal, tax, and total for the purchase, all formatted as currency.
write a driver class that contains a main method.
Instantiate at least three new items.
Create a new purchase
Add several items to the purchase
Print a receipt
Comment