package com.tech.Apple;
import com.sun.javaws.Main;
import java.util.ArrayList;
public class Invoice {
private static class Item{
String description;
int quantity;
double unitPrice;
public String getDescription() {
return description;
}
public int getQuantity() {
return quantity;
}
public double getUnitPrice() {
return unitPrice;
}
public Item() {
}
public Item(String description, int quantity, double unitPrice) {
this.description = description;
this.quantity = quantity;
this.unitPrice = unitPrice;
}
double price(){
return quantity * unitPrice;
}
}
private ArrayList<Item> items = new ArrayList<>();
public void add(Item item){
items.add(item);
System.out.println(item.getDescription() + "\t" + item.getQuantity() + "\t" + item.getUnitPrice() + "\t" + item.price());
}
public void addItem(String description, int quantity, double unitPrice){
Item item = new Item();
item.description = description;
item.quantity = quantity;
item.unitPrice = unitPrice;
System.out.println(item.getDescription() + "\t" + item.getQuantity() + "\t" + item.getUnitPrice() + "\t" + item.price());
}
public static void main(String[] args) {
Invoice.Item newItem = new Invoice.Item("BlackWell Toaster",2,19.95);
System.out.println(newItem.getDescription() + "\t" + newItem.getQuantity() + "\t" + newItem.getUnitPrice() + "\t" + newItem.price());
Invoice iv = new Invoice();
iv.add(newItem);
iv.addItem("pen",2,5);
}
}