Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
35dfb3b
Add domain model
shyye Aug 19, 2024
634a27a
Fix spelling error
shyye Aug 19, 2024
a9569d2
Update domain model
shyye Aug 19, 2024
91e5a14
Update domain model
shyye Aug 19, 2024
2c21df1
Update domain model with class diagram
shyye Aug 19, 2024
7f7b549
Update domain model
shyye Aug 19, 2024
a7f7d37
Add checkInventoryInitialization test
shyye Aug 19, 2024
aba8870
Update checkInventoryInitialization test
shyye Aug 20, 2024
d941db0
Add code for Inventory and corresponding classes
shyye Aug 20, 2024
f306d6a
Add addCoffee test
shyye Aug 20, 2024
cf697ec
Update checkInventoryInitialization test
shyye Aug 21, 2024
038f717
Add inventory and initalization functions
shyye Aug 21, 2024
f082ddc
Update setSKU function
shyye Aug 21, 2024
bf6356d
Add test comment
shyye Aug 21, 2024
1877341
Add getProduct functions
shyye Aug 21, 2024
1367ffc
Add addCoffee test
shyye Aug 21, 2024
5c96fcb
Add addCoffee function
shyye Aug 21, 2024
b3c2257
Add Test
shyye Aug 21, 2024
ee6ee48
Add addBagel and addFilling functions
shyye Aug 21, 2024
c89d317
Add Test
shyye Aug 21, 2024
d734d67
Fix addBagel with filling functions
shyye Aug 21, 2024
d1103b7
Add Test
shyye Aug 21, 2024
6c1a853
Add remove function and refactored
shyye Aug 21, 2024
da4e825
Add comment
shyye Aug 21, 2024
6c7d5f4
Add Test
shyye Aug 22, 2024
abbd432
Add addToBasket protected function
shyye Aug 22, 2024
eeef00e
Add custom exception
shyye Aug 22, 2024
4ad990d
Add comments to Maxcapacity test
shyye Aug 22, 2024
79b4715
Add Test: checkChangeCapacity
shyye Aug 22, 2024
e25ba57
Update code
shyye Aug 22, 2024
c532786
Add comment
shyye Aug 22, 2024
b780c9c
Update code
shyye Aug 22, 2024
34303f0
Remake of inventory in another package
shyye Aug 22, 2024
02c05d5
Test for new Inventory class
shyye Aug 22, 2024
02c5ded
Add classes for new inventory
shyye Aug 22, 2024
7a59496
Comment on test
shyye Aug 22, 2024
e900dc4
Comment on code
shyye Aug 22, 2024
c78d1ba
Add Test: getItemBasedOnSKU
shyye Aug 22, 2024
6379d7a
Add getItem() and getAllItems()
shyye Aug 22, 2024
fb31b28
Add Test: throwExceptionWhenItemIsNotInInventory
shyye Aug 22, 2024
cdffb63
Add exception case for getItem()
shyye Aug 22, 2024
970b2fe
Add Test: printInventoryMenu
shyye Aug 22, 2024
4c357b5
Add PrintGenerator and refactor Inventory
shyye Aug 22, 2024
9f49467
Add Test for new Basket class
shyye Aug 22, 2024
f34edf0
Update Test for new Basket class
shyye Aug 22, 2024
fe1176e
Refactor code for Basket functionality
shyye Aug 22, 2024
f751087
Refactor code and test
shyye Aug 22, 2024
67e83d9
Refactor code and test for adding bagel with fillings
shyye Aug 23, 2024
764dd91
Refactor code and test for rmeoving bagel with its fillings
shyye Aug 23, 2024
0d9dfe5
Simplify asserion to Asserions.assertNull
shyye Aug 23, 2024
f5bdbf0
Refactor code and test for exceeding max capacity
shyye Aug 23, 2024
4c3c572
Refactor code and test for exceeding max capacity
shyye Aug 23, 2024
8d13b41
Refactor code and test for change max capacity
shyye Aug 23, 2024
58b1693
Refactor code and test for exception when removing item that doesn't …
shyye Aug 23, 2024
0b0a069
Add Test: getTotalCostOfBasket
shyye Aug 23, 2024
4a40572
Add getTotalCost() and updateTotalCost()
shyye Aug 23, 2024
6fddda0
Add Test: getPriceOfBagel
shyye Aug 23, 2024
a3801e3
Add PriceCalculator with rounding function
shyye Aug 23, 2024
687a345
Update calculate price
shyye Aug 23, 2024
e0b2b66
Update test
shyye Aug 23, 2024
de4cd78
Merge pull request #1 from shyye/main2
shyye Aug 23, 2024
101604a
Refactor, delete old files
shyye Aug 23, 2024
8d6530d
Clean up code
shyye Aug 23, 2024
769e01c
Simplify remove()
shyye Aug 23, 2024
908f728
Simplify add()
shyye Aug 23, 2024
93bee08
remove updateTotalCost(), only use getTotalCost()
shyye Aug 23, 2024
b3f044a
Add total cost variable for basket
shyye Aug 23, 2024
3c1b7d6
Update imports
shyye Aug 23, 2024
d291f20
Clean up
shyye Aug 24, 2024
e5ad819
Moved files, automatic refactor on imports
shyye Aug 24, 2024
354d97c
Update enums, calculators, inventory
shyye Aug 24, 2024
cad76e6
Update inventory
shyye Aug 24, 2024
14ed5db
Update inventory
shyye Aug 24, 2024
f34d364
Re-order methods and members
shyye Aug 24, 2024
4bed7c6
Re-order class members
shyye Aug 24, 2024
2649fde
Small fix
shyye Aug 24, 2024
daa8c03
Update domain model
shyye Aug 24, 2024
a93bd75
Update domain model with printgenerator classes
shyye Aug 24, 2024
63611ae
Add Text: calcualte discount
shyye Aug 25, 2024
aed5832
Add special offers to Inventory
shyye Aug 25, 2024
2eedc4b
Add special offer classes
shyye Aug 25, 2024
a85822c
Add calculateDiscount to PriceCalcualtor
shyye Aug 25, 2024
4956c84
Update test
shyye Aug 25, 2024
18529cf
Restruct code
shyye Aug 25, 2024
f2db79b
Add Test for discount
shyye Aug 26, 2024
4b5704b
Update code for discount
shyye Aug 26, 2024
48b2a77
Update comments
shyye Aug 26, 2024
30ac94d
Update comments
shyye Aug 26, 2024
b5416b2
Update domain model for Extension 1
shyye Aug 26, 2024
3692ace
Add readme for core and extensions comments
shyye Aug 26, 2024
0115f30
Add printCheck in Test
shyye Aug 26, 2024
47ca7c5
Update code, change structure, a bit overcomplicated
shyye Aug 26, 2024
eb1fd82
Update code, change structure, a bit overcomplicated
shyye Aug 26, 2024
87e5fc7
Update domain and readme
shyye 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
Binary file added assets/images/class_diagram_basket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/class_diagram_inventory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/class_diagram_printGenerator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/gleek_class-diagram_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions src/main/java/com/booleanuk/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Bob's Bagels OOP

NOTES!
- I have done Core and Extension 1-3
- The domain model and class diagram are in [domain-model.md](domain-model.md)
- The classes printInventoryMenu and printInventoryBasket were created during the core part and are not a part of the requirements
- I did overthink a lot in this exercise, I'm not happy with all parts at the end, I think it could be much more simplified.
- There are some code duplications and I have commented "TODO:" on things I'm unsure about or things I think could be designed better.

## Core requirements
- [x] #1 I'd like to add a specific type of bagel to my basket.
- [x] #2 I'd like to remove a bagel from my basket.
- [x] #3 I'd like to know when my basket is full when I try adding an item beyond my basket capacity.
- [x] #4 I’d like to change the capacity of baskets.
- [x] #5 I'd like to know if I try to remove an item that doesn't exist in my basket.
- [x] #6 I'd like to know the total cost of items in my basket.
- [x] #7 I'd like to know the cost of a bagel before I add it to my basket.*
- [x] #8 I'd like to be able to choose fillings for my bagel.
- [x] #9 I'd like to know the cost of each filling before I add it to my bagel order.*
- [x] #10 I want customers to only be able to order things that we stock in our inventory.**

\* The inventory have functionality to print out the menu, but there are no functions that follows abstraction like
'getAllBagels()' etc. There is only functionality to get the inventory Map/List that contains objects with getPrice() functions.

** The inventory doesn't count how many of each item in stock, but customers can only choose things that are in the inventory.

## Extension 1

### User Stories

```
1.
As a manager,
So the customers can benefit from our discounts,
I want the discounts for all items in basket to be calculated autoamtically.
```

### Comments
- Added the classes SpecailOffer, SpecialOfferCombination, SpecialOfferMultiPrice to 'package: inventory'
- Added the classes DiscountObjectCombination and DiscountObjectMultiPrice to 'package: calculators'. Because the discount is calculated in the PriceCalculator class.

### Method/Calculation notes
```
# Discounts

if discount 6 for 2.55
get normalPrice
normalPrice - discountPrice = discount

get all items with SKU X
6 // numOfItems = number of discounts
number of discounts * discount.

result for this SKU = totalCost - totalDiscount

if discount is Coffe + Bagel = 1.33
get normalPrice
normalPrice - discountPrice = discount

get all occurencies of product A
get all occurencies of product B

if one or both is 0 -> no discount
if A = B -> discounts on all pairs
if A < B -> discount * the same number as A
and vice versa
```

## Extension 2

### User Stories

```
1.
As a customer,
So I can see that the order is correct,
I want to have a receipts what shows each item, the price, and how many of each item I ordered.
```

```
2.
As a customer,
So I can see an overview of my order,
I want to see the total cost of my order the receipt.
```

```
3.
As a customer,
So I can know when I placed my order,
I want to see the date and time for the order on the receipt.
```

### Comments
- Added printReceipt() in Basket
- Added PrintReceipt which extends PrintGenerator

## Extension 3
- Added printDiscountReceipt() in Basket
- Added PrintDiscountReceipt which extends PrintGenerator
30 changes: 30 additions & 0 deletions src/main/java/com/booleanuk/core/basket/Bagel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.booleanuk.core.basket;

import java.util.ArrayList;
import java.util.List;

public class Bagel extends BasketItem {

private List<String> linkedFillingSKUs;
private List<Integer> linkedFillingIds; // Id's for the fillings to this Bagel

public Bagel(String SKU) {
super(SKU);
linkedFillingSKUs = new ArrayList<>();
linkedFillingIds = new ArrayList<>();
}

public Bagel(String SKU, List<String> linkedFillingsSKUs) {
super(SKU);
this.linkedFillingSKUs = linkedFillingsSKUs;
this.linkedFillingIds = new ArrayList<>();
}

public List<String> getLinkedFillingSKUs() {
return linkedFillingSKUs;
}

public List<Integer> getLinkedFillingIds() {
return linkedFillingIds;
}
}
Loading