-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCart.java
More file actions
33 lines (30 loc) · 953 Bytes
/
Cart.java
File metadata and controls
33 lines (30 loc) · 953 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
import java.util.ArrayList;
import java.util.List;
public class Cart extends Cartop{
List<Product> items=new ArrayList<>();
@Override
void productByName(String pname) {
Product product=null;
List<Product> products = new ProductStr().getProduct();
for (Product prod: products) {
if (prod.getName().equalsIgnoreCase(pname)) {
product = prod;
items.add(product);
break;
}
else {
System.out.println("product is not available");
break;
}
}
}
void printCartItems() {
for (Product pro : items) {
System.out.println(
"\nProductId:"+ pro.getId()+
"\nName of the product : " +pro.getName()+
"\nPrice: "+pro.getPrice()+
"\nQuantity: "+pro.getQunty());
}
}
}