Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 230 additions & 0 deletions Inventory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
* Tracks the restaurant's inventory of ingredients and supplies
*/
import java.util.Scanner;

public class Inventory {
/*
* attributes
*/
private int cup;
private int tea;
private int milk;
private int boba;
private double cupBuyIn;
private double teaBuyIn;
private double milkBuyIn;
private double bobaBuyIn;

/*
* constructor that create inventory with default value
*/
public Inventory(){
this.cup = 5;
this.tea = 5;
this.milk = 5;
this.boba = 5;
this.cupBuyIn = 0.5;
this.teaBuyIn = 1;
this.milkBuyIn = 1;
this.bobaBuyIn = 0.5;
}

/**
* getter of cup quantity
* @return cup
*/
public int getCup() {
return cup;
}

/**
* getter of tea quantity
* @return tea
*/
public int getTea() {
return tea;
}

/**
* getter of milk quantity
* @return milk
*/
public int getMilk() {
return milk;
}

/**
* getter of boba quantity
* @return boba
*/
public int getBoba() {
return boba;
}

/**
* getter of cup price
* @return cupBuyIn
*/
public double getCupBuyIn() {
return cupBuyIn;
}

/**
* getter of tea price
* @return teaBuyIn
*/
public double getTeaBuyIn() {
return teaBuyIn;
}

/**
* getter of milk price
* @return milkBuyIn
*/
public double getMilkBuyIn() {
return milkBuyIn;
}

/** getter of boba price
* @return bobaBuyIn
*/
public double getBobaBuyIn() {
return bobaBuyIn;
}

/**
* Setter of cup
* @param cup
*/
public void setCup(int cup) {
this.cup = cup;
}

/**
* Setter of tea
* @param tea
*/
public void setTea(int tea) {
this.tea = tea;
}

/**
* Setter of milk
* @param milk
*/
public void setMilk(int milk) {
this.milk = milk;
}

/**
* Setter of boba
* @param boba
*/
public void setBoba(int boba) {
this.boba = boba;
}

/**
* accessor of inventory
* @return inventoryList string that describes inventory
*/
public String getInventoryList() {
String inventoryList = "\nCurrent Inventory:\n" +"----------------\n"
+ "a. Cups: " + cup + "\tBuy in price: " + cupBuyIn
+ "\nb. Tea: " + tea + "\tBuy in price: " + teaBuyIn
+ "\nc. Milk: " + milk + "\tBuy in price: " + milkBuyIn
+ "\nd. Boba: " + boba + "\tBuy in price: " + bobaBuyIn
+ "\n----------------";
return inventoryList;
}

/**
* @param itemType
* @param quantity
* @return cost for restock
*/
public double restockCost(String itemType, int quantity) {
switch (itemType) {
case "a":
return cupBuyIn * quantity;
case "b":
return teaBuyIn * quantity;
case "c":
return milkBuyIn * quantity;
case "d":
return bobaBuyIn * quantity;
default:
return 0;
}
}

/**
* method that restock in different cases
* @param store
* @param input
* @param number
* @param in
*/
public void restock(Store store, String input, int number, Scanner in){
boolean response;
switch (input) {
case "a":
if (store.getBalance() >= cupBuyIn * number) {
System.out.println("Purchase confirmed?");
response = handleInput.handleYesNoInput(in);
if (response) {
store.setBalance(store.getBalance() - cupBuyIn * number);
this.cup += number;
}
} else {
System.out.println("Insufficient balance.");
}
break;

case "b":
if (store.getBalance() >= teaBuyIn * number) {
System.out.println("Purchase confirmed?");
response = handleInput.handleYesNoInput(in);
if (response) {
store.setBalance(store.getBalance() - teaBuyIn * number);
this.tea += number;
}
} else {
System.out.println("Insufficient balance.");
}
break;

case "c":
if (store.getBalance() >= milkBuyIn * number) {
System.out.println("Purchase confirmed?");
response = handleInput.handleYesNoInput(in);
if (response) {
store.setBalance(store.getBalance() - milkBuyIn * number);
this.milk += number;
}
} else {
System.out.println("Insufficient balance.");
}
break;

case "d":
if (store.getBalance() >= bobaBuyIn * number) {
System.out.println("Purchase confirmed?");
response = handleInput.handleYesNoInput(in);
if (response) {
store.setBalance(store.getBalance() - bobaBuyIn * number);
this.boba += number;
}
} else {
System.out.println("Insufficient balance.");
}
break;

default:
System.out.println("Invalid input.");
break;
}
}
}

51 changes: 51 additions & 0 deletions Menu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* class that aggregate all menu items
*/
import java.util.Random;
import java.util.ArrayList;
import java.util.List;

public class Menu {
/*
* aggregation of objects in menuItem class
*/
public List<menuItem> items;

/**
* constructor
*/
public Menu() {
items = new ArrayList<>();
}

/**
* method that add menuitem to the list
* @param item
*/
public void addMenuItem(menuItem item) {
items.add(item);
}

/**
* method that return menu list
* @return menuList
*/
public String getMenuList() {
StringBuilder menuList = new StringBuilder("Menu Details:\n" + "----------------\n");
for (menuItem item : items) {
menuList.append(item.getMenuItem()).append("\n");
}
menuList.append("----------------");
return menuList.toString();
}

/**
* method that randomly generate a menu item
* @return an object from menuItem
*/
public menuItem getRandomMenuItem() {
Random random = new Random();
int index = random.nextInt(items.size());
return items.get(index);
}
}
94 changes: 94 additions & 0 deletions MenuItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Manages the menu items and their properties
*/
public class menuItem {
/*
* attributes
*/
private String name;
private int tea;
private int milk;
private boolean extraSize;
private boolean boba;
private double price;

/**
* constructor
* @param name
* @param tea
* @param milk
* @param extraSize
* @param boba
* @param price
*/
public menuItem(String name, int tea, int milk, boolean extraSize, boolean boba, double price){
this.name = name;
this.tea = tea;
this.milk = milk;
this.extraSize = extraSize;
this.boba = boba;
this.price = price;
}

/**
* getter of name
* @return name
*/
public String getName() {
return name;
}

/**
* method that return inventory of tea
* @return tea
*/
public int getTea() {
return tea;
}

/**
* method that return inventory of milk
* @return milk
*/
public int getMilk() {
return milk;
}

/**
* method that returns boolean value for extra size
* @return extraSize
*/
public boolean isExtraSize() {
return extraSize;
}

/**
* method that returns boolean value for boba
* @return boba
*/
public boolean isBoba() {
return boba;
}

/**
* getter of price
* @return price
*/
public double getPrice() {
return price;
}

/**
* method that return single menu item
* @return menu description
*/
public String getMenuItem() {
return "Name: " + name +
"\tTea: " + tea +
"\tMilk: " + milk +
"\tExtra Size: " + extraSize +
"\tBoba: " + boba +
"\tPrice: " + price;
}
}

Loading