Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d07ecdb
First commit, domain model and class diagram
JosteinRuen Aug 19, 2024
947ee83
Created empty classes, first test for additem
JosteinRuen Aug 19, 2024
f2321e9
First test addItem GREEN
JosteinRuen Aug 19, 2024
98839ce
RemoveItem test
JosteinRuen Aug 19, 2024
b1d79c9
removeitem test and code
JosteinRuen Aug 19, 2024
1ad21fe
changeBasketSize test
JosteinRuen Aug 19, 2024
4bcd0cb
changeBasketSize test and code
JosteinRuen Aug 19, 2024
b502367
checkpricetest and code
JosteinRuen Aug 19, 2024
477308b
addfilling test
JosteinRuen Aug 19, 2024
c015e54
addfilling test and code
JosteinRuen Aug 19, 2024
62fc097
addfilling test and code half done
JosteinRuen Aug 19, 2024
1e9f27b
All core requirements met
JosteinRuen Aug 20, 2024
a1c6805
addDiscountTest
JosteinRuen Aug 20, 2024
6649d53
first draft of addDiscount (Not working correctly)
JosteinRuen Aug 20, 2024
a841d4a
ADddiscount working (missing coffee + bagel discount)
JosteinRuen Aug 20, 2024
2c42d22
add discount tests, and updated domain models
JosteinRuen Aug 21, 2024
277e6e6
PrintReciept refactor
JosteinRuen Aug 22, 2024
ac6d08d
PrintReciept refactor 2, with accounting for variant
JosteinRuen Aug 22, 2024
38a36e7
refactoring print reciept to use helper methods
JosteinRuen Aug 22, 2024
7036c1b
print receipt refactor DONE
JosteinRuen Aug 22, 2024
17c7db5
print receipt refactor DONE
JosteinRuen Aug 22, 2024
ac738e3
updated gleek class diagram and some basket tests
JosteinRuen Aug 26, 2024
442ee8c
toString update
JosteinRuen Aug 26, 2024
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
119 changes: 119 additions & 0 deletions domain-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
User Stories

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.

11.
As a customer,
So i know how much i'm saving
I want to see my total cost bfore and after applying discounts

12.
As a customer,
So I know what i'm paying for
I want to see each individual idem on the receipt accompanied with the cost.

Basket Class

| Method Variables | Methods | Scenario | Output | User Story |
|----------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------|------------------------------------------------------------------|-------------|
| ArrayList<Product> basketContent | addItem(String SKU) | Basket full | Print error, return false | 1, 3, 8, 10 |
| ArrayList<Product> inventory | | Basket not full | print cost of item, return true | |
| int totalPrice | | | | |
| int basketSize | removeItem(String SKU) | Basket contains item | remove item from basketContent, return true | 2, 5 |
| | | Basket doesnt' contain item | print error, return false | |
| | | | | |
| | changeBasketSize(int newSize) | newSize is negative number | print error, return false | 4 |
| | | newSize is a positive number | print success, return true | |
| | | | | |
| | checkPrice() | | Prints totalPrice | 6 |
| | | | | |
| | addFilling(String SKU) | SKU corresponds to a bagel in basket | print price of filling<br/> add to basketContent<br/>return true | 7, 9 |
| | | SKU doesn't exist in basket | print error, return false | |
| | | | | |
| | addDiscount() | No discounted items | Return the totalPrice (Unchanged) | 11 |
| | | Discounted items | return the new totalPrice | |
| | | | | |
| | printReciet() | Basket is empty | print error | 12 |
| | | Basket is not empty | print the receipt including discounts | |
| | | | | |
| | addFilling(String bagelSKU, String FillingSKU) | Bagel doesn't have a filling,<br/>And filling SKU exists | Add filling to bagel object, return true | |
| | | Bagel doesn't have filling, but SKU doesn't exists | print error, return false | |
| | | | | |
| | addToMaps(Product p, Map<String, Int> countMap, Map<String, Double> priceMap) | | Adds the product p to the price and countmap | |
| | | | | |
| | printReceiptLines(String productType, Map<String, Integer> countMap, Map<String, Double> priceMap) | | Prints receit based on content of countMap and priceMap | |
| | | | | |
| | calculateTotal() | basketContent is empty | return 0 | |
| | | basketContent is not empty | return total price of basket items (WIthout discounts) | |
| | | | | |
| |

Product class

| Method Variables | Methods | Scenario | Output | User stories |
|------------------|--------------|----------|---------------|--------------|
| int SKU | getSKU() | | print SKU | |
| int price | getPrice() | | print price | |
| String name | getName() | | print name | |
| String variant | getVariant() | | print variant | |
| | | | | |
| | | | | |

The classes Coffee and Filling inherit from the product class, and have no unique variables or methods

Bagel class

| Method variables | Methods | Scenario | Output | user story |
|------------------|------------------------|----------------------------------------------------------|------------------------------------------|------------|
| Filling filling | getFilling() | Filling exists | return Filling object | 8 |
| | | Filling doesn't exist | print error, return null | |
| | | | | |
| | | | | |
Binary file added gleek-VdlCz2dQg2d4mnczqiReLw(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/main/java/com/booleanuk/core/Bagel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.booleanuk.core;

public class Bagel extends Product {
private Filling filling;

public Bagel (String SKU, double price, String name, String variant){
super(SKU, price, name, variant);
filling = null;
}

public Filling getFilling() {
return filling;
}

public void setFilling(Filling filling) {
this.filling = filling;
}

@Override
public String toString() {
return super.toString()+
" filling= " + filling +
'}';
}
}
Loading