-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCart.java
More file actions
executable file
·75 lines (64 loc) · 1.87 KB
/
Cart.java
File metadata and controls
executable file
·75 lines (64 loc) · 1.87 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.ArrayList;
/**
* Cart class creates the Product objects and stores them in ArrayList<Product> productList.
* It also creates a ArrayList<Float> which stores the total cost (including tax) of the
* Products in productList.
*
* @author Vanessa Esli Tovar
*/
public class Cart{
private ArrayList<Product> productList;
private ArrayList<Float> costsList;
private float totalCost;
private float totalTax;
/**
* Constructor
*/
public Cart(){
this.productList = new ArrayList<Product>();
this.costsList = new ArrayList<Float>();
this.totalCost = 0.0f;
this.totalTax = 0.0f;
}
/**
* Adds product to productList.
*
* @param name name of the product beind added
* @param quanity quanity of the product being added
* @param price price of the product being added (without tax)
* @param imported imported status of the product being added
* @param tax tax of the product being added
*/
public void addProduct(String name, int quantity, float price, boolean imported, float tax){
productList.add(new Product(name, quantity, price, imported));
costsList.add(new Float((quantity*price))+tax);
totalCost += quantity * price;
totalTax += tax;
}
/**
* Getter methods for productList.
*/
public ArrayList<Product> getProductList(){
return this.productList;
}
/**
* Getter method for costList.
*/
public ArrayList<Float> getCostsList(){
return this.costsList;
}
/**
* Getter method for total cost.
*/
public float getTotalCost(){
return totalCost;
}
/**
* Getter method for total tax.
*/
public float getTotalTax(){
return totalTax;
}
public static void main(String[] args){
}
}