Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package AI164.Tunon;
- import java.util.ArrayList;
- public class Cart<T extends Item> {
- private ArrayList<T> cart;
- private double cartAmount;
- public void print() {
- System.out.println("Cart : \n");
- this.cartAmount = 0;
- for (int i = 0; i < this.cart.size(); i++){
- System.out.println(this.cart.get(i).getName() + " price :" + this.cart.get(i).getPrice() + " $");
- this.cartAmount += this.cart.get(i).getPrice();
- }
- System.out.println("\nAmount : " + this.cartAmount + " $");
- }
- public void print(double percent) {
- System.out.println("Cart : \n");
- this.cartAmount = 0;
- for (int i = 0; i < this.cart.size(); i++){
- System.out.println(this.cart.get(i).getName() + " price :" + this.cart.get(i).changePrice(percent) + " $");
- this.cartAmount += this.cart.get(i).changePrice(percent);
- }
- System.out.println("\nAmount : " + this.cartAmount + " $");
- }
- public void add(T item){
- this.cart.add(item);
- }
- public Cart(int count) {
- this.cart = new ArrayList<T>(count);
- this.cartAmount = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement