diff --git a/Week-11-final-start/part-1/ItemToPurchase.java b/Week-11-final-start/part-1/ItemToPurchase.java index b942554..671abfe 100644 --- a/Week-11-final-start/part-1/ItemToPurchase.java +++ b/Week-11-final-start/part-1/ItemToPurchase.java @@ -7,7 +7,38 @@ * int itemQuanity - init to 0 * * Public member mothods (mutators & accessors) - * setName() & getName() * setPrice() & getPrice() - * setQuantity() & getQuantity() */ + +public class ItemToPurchase { + private String itemName; + private int itemPrice; + private int itemQuantity; + + public ItemToPurchase() { + itemName = "none"; + itemPrice = 0; + itemQuantity = 0; + } + public void setName(String name){ + this.itemName = name; + } + public String getName(){ + return itemName; + } + public void setQuantity(int q){ + this.itemQuantity = q; + } + public int getQuantity(){ + return itemQuantity; + } + public void setPrice(int p){ + this.itemPrice = p; + } + public int getPrice(){ + return itemPrice; + } + +} + + diff --git a/Week-11-final-start/part-1/ShoppingCartPrinter.java b/Week-11-final-start/part-1/ShoppingCartPrinter.java index 02466f7..12dd1b9 100644 --- a/Week-11-final-start/part-1/ShoppingCartPrinter.java +++ b/Week-11-final-start/part-1/ShoppingCartPrinter.java @@ -37,5 +37,34 @@ import java.util.Scanner; public class ShoppingCartPrinter { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); + ItemToPurchase item1 = new ItemToPurchase(); + ItemToPurchase item2 = new ItemToPurchase(); + + + System.out.println("Item 1"); + System.out.println("Enter the item name:"); + item1.setName(scnr.nextLine()); + + System.out.println("Item 2"); + System.out.println("Enter the item name:"); + item2.setName(scnr.nextLine()); + + System.out.println("TOTAL COST"); + System.out.println(item1.getName() + " " + item1.getQuantity() + + " @ $" + item1.getPrice() + " = $" + + (item1.getPrice() * item1.getQuantity())); + + System.out.println(item2.getName() + " " + item2.getQuantity() + + " @ $" + item2.getPrice() + " = $" + + (item2.getPrice() * item2.getQuantity())); + System.out.println("\n Total: $" + + ((item2.getPrice() * item2.getQuantity()) + + (item1.getPrice() * item2.getQuantity()))); + + scnr.close(); + + + + } }