-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartItem.java
More file actions
37 lines (32 loc) · 892 Bytes
/
Copy pathCartItem.java
File metadata and controls
37 lines (32 loc) · 892 Bytes
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
// import java.util.*;
import java.io.*;
public class CartItem implements Serializable {
private static final long serialVersionUID = 1L;
private Client client;
private Product product;
private int quantity;
public CartItem(Client client, Product product, int quantity) {
// this.product should be changed to reference the product instead of storing it
this.client = client;
this.product = product;
this.quantity = quantity;
}
public Client getClient() {
return client;
}
public Product getProduct() {
return product;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int q) {
quantity = q;
}
public double getPrice() {
return product.getPrice() * quantity;
}
public String toString() {
return "name: " + product.getName()+ " | quantity: " + getQuantity() + " | price: " + getPrice();
}
}