-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPanier.java
50 lines (41 loc) · 1.26 KB
/
Panier.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
45
46
47
48
49
50
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gl.project;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author gh
*/
public class Panier {
private final List<Produit> cartItems = new ArrayList<>();
private final List<Integer> quantities = new ArrayList<>();
private float totalPrice;
// Methods
public List<Produit> getCartItems() {
return cartItems;
}
public List<Integer> getQuantities() {
return quantities;
}
public float getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(float totalPrice) {
this.totalPrice = totalPrice;
}
public void calculateTotal() {
System.out.println("Total cart value: " + totalPrice);
}
public void afficherPanier() {
System.out.println("Products in the cart:");
for (int i = 0; i < cartItems.size(); i++) {
Produit product = cartItems.get(i);
int quantity = quantities.get(i);
System.out.println(product.getName() + " (Quantity: " + quantity + ")");
}
}
}