Skip to content
92 changes: 92 additions & 0 deletions domain-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Bobs bagels

## Item

| Method | Member Variable | Scenario | Result |
|---------------------|---------------------|----------|--------|
| | Double price | | |
| | String name | | |
| | String abbreviation | | |
| Getters and setters | | | |

### Bagel
#### SesameBagel
#### OnionBagel
#### EverythingBagel
#### PlainBagel

### Filling
#### HamFilling
#### SmokedSalmonFilling
#### CreamCheeseFilling
#### CheeseFilling
#### EggFilling
#### BaconFilling

### Coffee
#### BlackCoffee
#### WhiteCoffee
#### CappuccinoCoffee
#### LatteCoffee

## Basket
| Method | Member Variable | Scenario | Result |
|------------------------------|-----------------------|----------------------------------------------------|--------------------------------|
| | ArrayList<Item> items | | |
| | Int basketSize | | |
| add(Item item) | | Adding an item to a basket which is not full | String "successfully added" |
| | | Adding an item to a basket which is full | String "Basket is full" |
| | | Adding an item not in inventory to a basket | String "Item not in inventory" |
| | | | |
| remove(String item) | | Removing an existing item | String "Successfully removed" |
| | | Removing an item that does not exist | String "No item found" |
| | | | |
| resizeBasket(int newSize) | | Resizing the basket to an accepted size | true |
| | | Resizing the basket to an unaccepted size | false |
| | | | |
| calculateTotalCostOfBasket() | | Trying to calculate cost of a basket with items | Double totalCost |
| | | Trying to calculate cost of a basket with no items | Double 0 |

## Menu

| Method | Member Variable | Scenario | Result |
|----------------------------------|--------------------------------|--------------------------------------------------------------|--------------------------|
| | ArrayList<Item> allUniqueItems | | |
| listAllFillingPrices() | | List all the filling prices in the Menu and are in inventory | String prices |
| | | | |
| checkCostOfItem(String itemName) | | Check cost of an item that exists | String "Price: " + price |
| | | Check cost of an item that does not exist | String "No item found" |
| | | | |
| isInInventory(String itemName) | | Search for an item currently in inventory | true |
| isInInventory(String itemName) | | Search for an item currently not in inventory | false |

# Extension
## Receipt
| Method | Member Variable | Scenario | Result |
|-----------------|--------------------------|--------------------------------------|----------------|
| | HashMap<Item, int> items | | |
| | Many more... | | |
| | | | |
| printReceipt() | | Print receipt of all items in basket | String receipt |

## Basket
## Basket
| Method | Member Variable | Scenario | Result |
|-----------------------------------------------------|-----------------------|----------------------------------------------------|--------------------------------|
| | ArrayList<Item> items | | |
| | Int basketSize | | |
| add(Item item) | | Adding an item to a basket which is not full | String "successfully added" |
| | | Adding an item to a basket which is full | String "Basket is full" |
| | | Adding an item not in inventory to a basket | String "Item not in inventory" |
| | | | |
| remove(String item) | | Removing an existing item | String "Successfully removed" |
| | | Removing an item that does not exist | String "No item found" |
| | | | |
| resizeBasket(int newSize) | | Resizing the basket to an accepted size | true |
| | | Resizing the basket to an unaccepted size | false |
| | | | |
| calculateTotalCostOfBasket() | | Trying to calculate cost of a basket with items | Double totalCost |
| | | Trying to calculate cost of a basket with no items | Double 0 |
| --Extension version-- | | | |
| calculateTotalCostOfBasketWithDiscounts() | | | Double totalCost |
| calculateTotalCostOfBasketWithDiscountsAndReceipt() | | | String receipt |
Binary file added gleek-Y4rWchvhyN9gG79FMj1c_A (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/main/java/com/booleanuk/core/BaconFilling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.booleanuk.core;

public class BaconFilling extends Filling{
public BaconFilling(){
name = "Bacon";
price = 0.12;
abbreviation = "FILB";
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/booleanuk/core/Bagel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.booleanuk.core;

public class Bagel extends Item {

}
70 changes: 70 additions & 0 deletions src/main/java/com/booleanuk/core/Basket.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.booleanuk.core;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;

public class Basket {

private ArrayList<Item> items;
private int basketSize;

public Basket(){
items = new ArrayList<>();
basketSize = 100;
}

public String add(Item item, Menu menu){
String msg = "";
if(!menu.isInMenu(item)){
msg = "Item not on the menu";
return msg;
}
if(items.size() >= basketSize){
return msg = "Basket is full";
}
items.add(item);
if(menu.isInMenu(item)){
msg = "Successfully added";

}
return msg;

}

public String remove(String itemName){
String msg = "";
for (Item i : items){
if(i.getName() == itemName){
items.remove(i);
msg = "Successfully removed";
return msg;
}

}

msg = "No item found";

return msg;
}

public Boolean resizeBasket(int newSize){
if(newSize>15){
return false;
}
basketSize = newSize;
return true;
}

public Double calculateTotalCostOfBasket(){
double total = 0;

for(Item i : items){
total += i.getPrice();
}

return total;
}


}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/BlackCoffee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class BlackCoffee extends Coffee{

public BlackCoffee(){
name = "Black";
price = 0.99;
abbreviation = "COFB";
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/CappuccinoCoffee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class CappuccinoCoffee extends Coffee{

public CappuccinoCoffee(){
name = "Cappuccino";
price = 1.29;
abbreviation = "COFC";
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/CheeseFilling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class CheeseFilling extends Filling{

public CheeseFilling(){
name = "Cheese";
price = 0.12;
abbreviation = "FILC";
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/booleanuk/core/Coffee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.booleanuk.core;

public class Coffee extends Item{
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/CreamCheeseFilling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class CreamCheeseFilling extends Filling{

public CreamCheeseFilling(){
name = "CreamCheese";
price = 0.12;
abbreviation = "FILX";
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/EggFilling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class EggFilling extends Filling{

public EggFilling(){
name = "Egg";
price = 0.12;
abbreviation = "FILE";
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/EverythingBagel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class EverythingBagel extends Bagel{

public EverythingBagel(){
name = "Everything";
price = 0.49;
abbreviation = "BGLE";
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/booleanuk/core/Filling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.booleanuk.core;

public class Filling extends Item{
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/HamFilling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class HamFilling extends Filling{

public HamFilling(){
name = "Ham";
price = 0.12;
abbreviation = "FILH";
}
}
19 changes: 19 additions & 0 deletions src/main/java/com/booleanuk/core/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.booleanuk.core;

public class Item {
protected double price;
protected String name;
protected String abbreviation;

public double getPrice() {
return price;
}

public String getName() {
return name;
}

public String getAbbreviation() {
return abbreviation;
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/booleanuk/core/LatteCoffee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.booleanuk.core;

public class LatteCoffee extends Coffee{

public LatteCoffee(){
name = "Latte";
price = 1.29;
abbreviation = "COFL";
}
}
91 changes: 91 additions & 0 deletions src/main/java/com/booleanuk/core/Menu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.booleanuk.core;

import java.util.ArrayList;
import java.util.Objects;

public class Menu {

private ArrayList<Item> currentMenu;

public Menu(){
currentMenu = new ArrayList<>();
fillMenu();
}

public String listAllFillingPrices(){
String pricingList = "";
for(Item item : currentMenu){
if(item.getAbbreviation().contains("FIL")){
pricingList += "Name: " + item.getName() + ", Price: " + item.getPrice() + "\n";
}


}
return pricingList;
}

public String checkCostOfItem(String itemName){
String price = "No item found";
for(Item item : currentMenu){
if(item.getName().equals(itemName)){
price = "Price: " + item.getPrice();
return price;
}

}
return price;

}

public Boolean isInMenu(Item item){
for(Item i : currentMenu){
if(Objects.equals(i.getName(), item.getName())){
return true;
}
}
return false;
}

public Boolean isInMenu(String name){
for(Item i : currentMenu){
if(Objects.equals(i.name, name)){
return true;
}
}
return false;
}

private void fillMenu(){

Item onionBagel = new OnionBagel();
currentMenu.add(onionBagel);
Item plainBagel = new PlainBagel();
currentMenu.add(plainBagel);
Item everythingBagel = new EverythingBagel();
currentMenu.add(everythingBagel);
Item sesameBagel = new SesameBagel();
currentMenu.add(sesameBagel);
Item blackCoffee = new BlackCoffee();
currentMenu.add(blackCoffee);
Item whiteCoffee = new WhiteCoffee();
currentMenu.add(whiteCoffee);
Item cappuccino = new CappuccinoCoffee();
currentMenu.add(cappuccino);
Item latte = new LatteCoffee();
currentMenu.add(latte);
Item bacon = new BaconFilling();
currentMenu.add(bacon);
// Item egg = new EggFilling();
// currentMenu.add(egg);
Item cheese = new CheeseFilling();
currentMenu.add(cheese);
Item creamCheese = new CreamCheeseFilling();
currentMenu.add(creamCheese);
Item smokedSalmon = new SmokedSalmonFilling();
currentMenu.add(smokedSalmon);
Item ham = new HamFilling();
currentMenu.add(ham);


}
}
Loading
Loading