-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSalesLineItem.java
executable file
·44 lines (32 loc) · 978 Bytes
/
SalesLineItem.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package ProcessSale;
// Class to hold info for a product in the cart
public class SalesLineItem {
//variables
int quantity;
ProductDescription desc;
//constructor
//pass in the id/barcode of the current lineitem
public SalesLineItem(String barcode, int qty){
desc = new ProductDescription(barcode);
quantity = qty;
}
//method to get the subtotal of the purchase after adding this current item
//to the sale
public double getSubtotal(){
return getPrice() * quantity;
}
// Get the Sale price of the item
public double getPrice() {
return desc.getSalePrice();
}
@Override
public String toString(){
return "Barcode: " + getBarcode() + ", Qty: " + quantity + ", $" + getSubtotal();
}
public String getBarcode() {
return desc.getBarcode();
}
public int getQuantity() {
return quantity;
}
}