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
97 changes: 97 additions & 0 deletions src/main/domain-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
```
1.
As a member of the public,
So I can order a bagel before work,
I'd like to add a specific type of bagel to my basket.
```
```
2.
As a member of the public,
So I can change my order,
I'd like to remove a bagel from my basket.
```
```
3.
As a member of the public,
So that I can not overfill my small bagel basket
I'd like to know when my basket is full when I try adding an item beyond my basket capacity.
```
```
4.
As a Bob's Bagels manager,
So that I can expand my business,
I’d like to change the capacity of baskets.
```
```
5.
As a member of the public
So that I can maintain my sanity
I'd like to know if I try to remove an item that doesn't exist in my basket.
```
```
6.
As a customer,
So I know how much money I need,
I'd like to know the total cost of items in my basket.
```
```
7.
As a customer,
So I know what the damage will be,
I'd like to know the cost of a bagel before I add it to my basket.
```
```
8.
As a customer,
So I can shake things up a bit,
I'd like to be able to choose fillings for my bagel.
```
```
9.
As a customer,
So I don't over-spend,
I'd like to know the cost of each filling before I add it to my bagel order.
```
```
10.
As the manager,
So we don't get any weird requests,
I want customers to only be able to order things that we stock in our inventory.
```

| Classes | Variables | Method | Scenario | Output |
|-----------|-----------------------|-----------------------------------------------------|-------------------------------------|--------------------------------------------|
| Member | Member.basket | boolean addBagel(Item type) | If type is valid | true |
| Basket | | | if cap is reached | false |
| Bagel | | | inventory is empty | false |
| -------- | ------------------- - | ------------------------------------------------ | ------------------------ | --------------------------------------- |
| Member | Member.basket | boolean removeFromBasket(string bagelName) | if bagel exists | true |
| | | | if bagel does not exist | false |
| | | | if basket is empty | false |
| -------- | --------------------- | ------------------------------------------------- | ------------------------ | --------------------------------------- |
| Basket | Basket.maxCapacity | boolean member.setCapacity(int cap) | if basketcap is negative | false |
| | Basket.items | | if Basketcap is 0-100 | true |
| | | | if bascetcap is >100 | false |
| -------- | -------------------- | --------------------------------------------------- | ------------------------ | ----------------------------------------- |
| Customer | Customer.totalcost | Float getTotalcost() | It the basket is empty | 0.00 |
| | | | if it has items | price of basket |
| | | | if item does not exist | false |
| | | | | |
| | Customer.addDiscount | Float addDiscount() | if basket does qualify for discount | return Float as the amount the discount is |
| | | | if basket does not have discount | return 0.00f |
| | | | | |
| | | | | |
| --------- | ------------------- | --------------------------------------------------- | ------------------------- | ----------------------------------------- |
| Customer | Item.price | Float getPrice(Item item) | if price for item found | price of item |
| --------- | --------------------- | ------------------------------------------------- | ----------------------- | ---------------------------------------- |
| | | | | |
| Basket | Basket.currentStock | boolean setCurrentStock(item item, Integer amount) | if item is valid | true |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
| | | | if item does not exist | false |
Binary file added src/main/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/main/java/com/booleanuk/core/Bagel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.booleanuk.core;

public class Bagel implements Item{
private Float price;
private String name;
private String type;
private String SKU;

public Bagel(Float price, String name, String type, String SKU) {
this.price = price;
this.name = name;
this.type = type;
this.SKU = SKU;
}

@Override
public Float getPrice() {
return price;
}

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

import java.util.ArrayList;
import java.util.HashMap;

public class Basket {
/// SHould this be List or ArrayList
private ArrayList<Item> items;

public Basket(ArrayList<Item> items) {
this.items = items;
}


//This is added for first test:
public boolean addItems( Item item){
if (checkStock(item) && getSize() < Manager.maxCapacity) {
items.add(item);
return true;
}
return false;
}

public Boolean checkStock(Item item) {
//check the key item, and check if it has any integers left.
if (Manager.currentStock.containsKey(item)){
Integer stock = Manager.currentStock.get(item);
System.out.println("the current stock: " + stock);
if (stock > 0) {
Manager.currentStock.put(item, stock-1);
return true;

}

}
return false;
}
public boolean removeItem(Item item){
if (items.contains(item)) {
items.remove(item);
return true;
}
return false;
}


public Integer getSize() {
return items.size();
}


public Float getTotalCost(){
Float sum = 0.00f;
for (Item item : items){
sum += item.getPrice();
}
return sum;
}


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

public class Coffe implements Item {
private Float price;
private String name;
private String type;
private String SKU;

public Coffe(Float price, String name, String type, String SKU) {
this.price = price;
this.name = name;
this.type = type;
this.SKU = SKU;
}


public Float getPrice() {
return price;
}

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

public class Customer extends Member{

public Customer(Basket basket) {
super(basket);
}

public Float getTotalCost() {
return basket.getTotalCost();
}
public Float getPrice(Item item){

return item.getPrice();
}


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

public class Filling implements Item {

private Float price;
private String name;
private String type;
private String SKU;

public Filling(Float price, String name, String type, String SKU) {
this.price = price;
this.name = name;
this.type = type;
this.SKU = SKU;
}


public Float getPrice() {
return price;
}


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

public interface Item {
//all getters and setters to all variables.
public Float getPrice();

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

public class Main {
public static void main(String[] args) {

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

import java.util.HashMap;
import java.util.Map;

public class Manager {
public static HashMap<Item, Integer> currentStock; //Should I use hashMap instead here maybe?
public static Integer maxCapacity;


public Manager(HashMap<Item, Integer> currentStock, Integer maxCapacity) {

Manager.currentStock = currentStock;
Manager.maxCapacity = maxCapacity;
}

public boolean setMaxCapacity(Integer maxCapacity) {
if (maxCapacity >0 && maxCapacity <= 100){
Manager.maxCapacity = maxCapacity;
return true;
}
return false;
}

public static boolean setCurrentStock(Item item, Integer quantity){
if (item!=null){
Manager.currentStock.put(item, quantity);
return true;
}
return false;
}




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

public class Member {
protected Basket basket;

public Member(Basket basket) {
this.basket = basket;
}

public boolean addToBasket(Item item){
return basket.addItems(item);
}

public boolean removeFromBasket(Item item){
return basket.removeItem(item);
}

}
Binary file added src/main/updatedclassmodel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading