-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mattias Hedbom #137
Open
Hedbom98
wants to merge
41
commits into
boolean-uk:main
Choose a base branch
from
Hedbom98:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Mattias Hedbom #137
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
3395af2
domain model completed
b9b3378
domain model, small adjustment
0df4efe
domain model, small adjustment
e5493fa
created all classes, also made som changes to the domain model
bb73d7c
Created the initial test for the seePrice() method in menu
e0df841
Created the initial seePrice() method
cf181db
Completed the seePrice() method/ test.
e47f0ea
initial method for showAllFillingsWithCosts() method
61539e3
Needed to add String typeOfItem to Item class, needed to list all fil…
e0c590a
Needed to add String typeOfItem to Item class, needed to list all fil…
f117ed5
completed method for showAllFillingsWithCosts()
ce17b92
completed method for isContainedInInventory()
33bbf21
initial method for isContainedInInventory completed
b2e74a3
Method for isContainedInInventory completed
b0c59a1
Updated the fields and the constructor for the basket-class
4b2f21b
Initial test for addItem() in basket-class completed
69ecfae
Initial method for addItem() in basket-class completed
7f1af65
Method for addItem() in basket-class completed, also added an extra t…
90de7a8
Initial method for removeItem() in basket-class completed
091017c
Initial method for removeItem() in basket-class completed
daa655c
Test for removeItem() in basket-class completed
20d515a
Method for removeItem() in basket-class completed
8976d17
Initial test for changeSizeOfBasket() in basket-class completed
58a3ec8
Initial method for changeSizeOfBasket() in basket-class completed. Al…
170742e
Method/ Test for changeSizeOfBasket() in basket-class completed.
dc14257
Initial Test for totalCost() in basket-class completed.
8f7593f
Initial method for totalCost() in basket-class completed.
91c47d2
Method / Test for totalCost() in basket-class completed.
69cc924
Domain model adjusted for extension 1. Tests made for method totalCos…
3dd314c
Forgot to write the code for the extension in the extension folder, t…
2efdac5
Forgot the discount for 1bagel and 1 coffee, added another test for this
2acf2ba
Forgot the discount for 1bagel and 1 coffee, completed the method to …
a31de45
Added the class diagrams, the one made before the extension and the o…
2ac4d45
made a small adjustment to the receipt class
ca5b30c
Created the test for the second extension, also created the Extension…
7aaddbf
redid the domain model for the receipt class, added two more methods:
7cab442
Test made for the costWithDiscounts() method
bed4182
method costWithDiscounts() completed
d5148b0
Discovered that I needed two parameters in my costWithDiscounts() met…
bb6e0ec
Method printReceipt() completed
271a052
Forgot to update the classDiagram for the extension part when I recen…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Bob's bagels | ||
|
||
## Menu | ||
| Method | Member variable | Scenario | Result | | ||
|-----------------------------------|-----------------------------|-------------------------------------------|--------------------------| | ||
| | ArrayList<item> itemsOnMenu | | | | ||
| seePrice(Item anItem) | | The item exist in the inventory | String show price | | ||
| | | The item dont exist in the inventory | String error message | | ||
| | | | | | ||
| showAllFillingsWithCosts() | | List all fillings in that are on the menu | String with all fillings | | ||
| | | | | | ||
| | | | | | ||
| isContainedInInventory(Item item) | | item is contained in the inventory | True | | ||
| | | item is not contained in the inventory | False | | ||
|
||
|
||
## Basket | ||
| Method | Member variable | Scenario | Result | | ||
|---------------------------------|-------------------------------|-----------------------------------|---------------------------------------------| | ||
| addItem(Item anItem) | ArrayList<Item> itemsInBasket | basket is full | String Error message | | ||
| | int size | basket is not full | String success message | | ||
| | | | | | ||
| removeItem(Item anItem) | | item is not contained in basket | String Error message | | ||
| | | item is contained in basket | String success message | | ||
| | | | | | ||
| changeSizeOfBasket(int newSize) | | entering acceptable size | True | | ||
| | | entering non-acceptable size | False | | ||
| | | | | | ||
| totalCost() | | basket consists of atleast 1 item | Double total cost of basket | | ||
| | | basket dont consist any items | 0 | | ||
| | | | | | ||
| //EXTENSION | | | | | ||
| totalCostWithDiscounts() | | discounts are received | Double total cost of basket minus discounts | | ||
| | | discounts are not received | Double total cost of basket | | ||
|
||
|
||
## Items | ||
| Method | Member Variable | Scenario | Result | | ||
|---------------------|---------------------|----------|--------| | ||
| | Double price | | | | ||
| | String abbreviation | | | | ||
| | String name | | | | ||
| | String typeOfItem | | | | ||
| getters and setters | | | | | ||
|
||
|
||
## Coffee | ||
| Method | Member Variable | Scenario | Result | | ||
|---------------------|---------------------|----------|--------| | ||
| | Float price | | | | ||
| | String abbreviation | | | | ||
| | String name | | | | ||
| getters and setters | | | | | ||
|
||
|
||
## Bagel | ||
| Method | Member Variable | Scenario | Result | | ||
|---------------------|---------------------|----------|--------| | ||
| | Float price | | | | ||
| | String abbreviation | | | | ||
| | String name | | | | ||
| getters and setters | | | | | ||
|
||
|
||
## Filling | ||
| Method | Member Variable | Scenario | Result | | ||
|---------------------|---------------------|----------|--------| | ||
| | Float price | | | | ||
| | String abbreviation | | | | ||
| | String name | | | | ||
| getters and setters | | | | | ||
|
||
|
||
|
||
// EXTENSION | ||
## Receipt | ||
|
||
| Method | Member Variable | Scenario | Result | | ||
|----------------------------------------------|----------------------------------------------|-----------------------------------|---------------------------------------------| | ||
| | HashMap<Item, Integer> itemsThatArePurchased | | | | ||
| | String dateOfPurchase | | | | ||
| printReceipt() | | basket consists of atleast 1 item | String receipt returned and is also printed | | ||
| | | basket dont contain any items | String Error message | | ||
| | | | | | ||
| totalCostWithDiscounts() | | discounts are received | Double total cost of basket minus discounts | | ||
| | | discounts are not received | Double total cost of basket | | ||
| | | | | | ||
| costWithDiscounts(Item anItem, int quantity) | | discounts are received | Double cost of item minus discounts | | ||
| | | discounts are not received | Double cost of item | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class BaconFilling extends Filling{ | ||
public BaconFilling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class Bagel extends Item{ | ||
public Bagel(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.booleanuk.core; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Basket { | ||
private ArrayList<Item> itemsInBasket; | ||
private int size; | ||
|
||
public Basket(ArrayList<Item> itemsInBasket, int size){ | ||
this.itemsInBasket = itemsInBasket; | ||
this.size = size; | ||
} | ||
|
||
public void setItemsInBasket(ArrayList<Item> itemsInBasket) { | ||
this.itemsInBasket = itemsInBasket; | ||
} | ||
|
||
public void setSize(int size) { | ||
this.size = size; | ||
} | ||
|
||
public String addItem(Item itemToAdd){ | ||
if(this.itemsInBasket.size() < this.size){ | ||
this.itemsInBasket.add(itemToAdd); | ||
return itemToAdd.getName() + " was added to your basket!"; | ||
} | ||
return "Basket is full!"; | ||
} | ||
|
||
public String removeItem(Item itemToRemove){ | ||
for(Item item : itemsInBasket){ | ||
if(item.getName().equals(itemToRemove.getName())){ | ||
itemsInBasket.remove(item); | ||
return itemToRemove.getName() + " was removed from the basket!"; | ||
} | ||
} | ||
return "Item do not exist in basket!"; | ||
} | ||
|
||
public boolean changeSizeOfBasket(int newSize){ | ||
if(newSize > 0 && newSize >= this.itemsInBasket.size()){ | ||
setSize(newSize); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public double totalCost(){ | ||
double totalCost = 0; | ||
for(Item item : this.itemsInBasket){ | ||
totalCost += item.getPrice(); | ||
} | ||
return totalCost; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class BlackCoffee extends Coffee{ | ||
public BlackCoffee(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class CappucinoCoffee extends Coffee{ | ||
public CappucinoCoffee(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class CheeseFilling extends Filling{ | ||
public CheeseFilling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.booleanuk.core; | ||
|
||
public class Coffee extends Item{ | ||
public Coffee(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class CreamCheeseFilling extends Filling{ | ||
public CreamCheeseFilling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class EggFilling extends Filling{ | ||
public EggFilling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class EverythingBagel extends Bagel{ | ||
public EverythingBagel(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.booleanuk.core; | ||
|
||
public class Filling extends Item{ | ||
public Filling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class HamFilling extends Filling{ | ||
public HamFilling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.booleanuk.core; | ||
|
||
public class Inventory { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.booleanuk.core; | ||
|
||
public class Item { | ||
private Double price; | ||
private String abbreviation; | ||
private String name; | ||
private String typeOfItem; | ||
|
||
public Item(Double price, String abbreviation, String name, String typeOfItem){ | ||
this.price = price; | ||
this.abbreviation = abbreviation; | ||
this.name = name; | ||
this.typeOfItem = typeOfItem; | ||
} | ||
|
||
public String getTypeOfItem() { | ||
return typeOfItem; | ||
} | ||
|
||
public Double getPrice() { | ||
return price; | ||
} | ||
|
||
public String getAbbreviation() { | ||
return abbreviation; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class LatteCoffee extends Coffee{ | ||
public LatteCoffee(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.booleanuk.core; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Menu { | ||
private ArrayList<Item> itemsOnMenu; | ||
|
||
public Menu(ArrayList<Item> itemsOnMenu){ | ||
this.itemsOnMenu = itemsOnMenu; | ||
} | ||
|
||
public String seePrice(Item itemToCheck){ | ||
for(Item anItem : itemsOnMenu){ | ||
if(anItem.getName().equals(itemToCheck.getName())){ | ||
return "The item costs: " + itemToCheck.getPrice(); | ||
} | ||
} | ||
|
||
return "Item dont exist on the menu!"; | ||
} | ||
|
||
public String showAllFillingsWithCosts(){ | ||
String allFillingsWithPrices = ""; | ||
for(Item anItem : this.itemsOnMenu){ | ||
if(anItem.getTypeOfItem().equals("Filling")){ | ||
allFillingsWithPrices += anItem.getName() + ", " + anItem.getPrice() + "$\n"; | ||
} | ||
} | ||
return allFillingsWithPrices; | ||
} | ||
|
||
|
||
public Boolean isContainedInInventory(Item itemToCheck){ | ||
for(Item anItem : itemsOnMenu){ | ||
if(anItem.getName().equals(itemToCheck.getName())){ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class OnionBagel extends Bagel{ | ||
public OnionBagel(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class PlainBagel extends Bagel{ | ||
public PlainBagel(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class SesameBagel extends Bagel{ | ||
public SesameBagel(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class SmokedSalmonFilling extends Filling{ | ||
public SmokedSalmonFilling(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.booleanuk.core; | ||
|
||
public class WhiteCoffee extends Coffee{ | ||
public WhiteCoffee(Double price, String abbreviation, String name, String typeOfItem){ | ||
super(price, abbreviation, name, typeOfItem); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use stringbuilder in place of concatenating strings in a loop, as strings are immutable, so a new string will be created at each iteration