-
Notifications
You must be signed in to change notification settings - Fork 109
Ateeb Salam #94
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
Open
Ateeb020301
wants to merge
6
commits into
boolean-uk:main
Choose a base branch
from
Ateeb020301: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
Ateeb Salam #94
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6cbbc65
Ateeb Salam 1.Member class
Ateeb020301 0d4bcee
Ateeb Salam 1.Member class
Ateeb020301 71b2ecf
Ateeb Salam 2.Member class
Ateeb020301 6b84455
Ateeb Salam 2.Member class
Ateeb020301 751aebc
Ateeb Salam 3.Member class
Ateeb020301 5ca77fe
Ateeb Salam 5.Member class
Ateeb020301 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
This file contains hidden or 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,45 @@ | ||
| # 1. Member class | ||
|
|
||
|
|
||
| | Methods | Member variables | Scenario | Outputs/Results/Return values | | ||
| |-----------------|------------------|--------------------|-------------------------------| | ||
| | addBagel(bagel) | String[] bagels | if bagel add | True | | ||
| | | | if bagel add exist | False | | ||
| | | | | | | ||
| | | | | | ||
|
|
||
| # 2. Member class | ||
|
|
||
| | Methods | Member variables | Scenario | Outputs/Results/Return values | | ||
| |------------------------------------|----------------------|------------------------|-------------------------------| | ||
| | removeBagel(bagels ,bagelBasket[]) | String[] bagelBasket | if bagel exists | True | | ||
| | | | if bagel doesn't exist | False | | ||
| | | | | | | ||
| | | | | | ||
|
|
||
| # 3. Member class | ||
|
|
||
| | Methods | Member variables | Scenario | Outputs/Results/Return values | | ||
| |---------------------------------------|-----------------------|-------------------|-------------------------------| | ||
| | basketCapacity(bagels ,bagelBasket[]) | String[] bagelsBasket | if basket full | True | | ||
| | | | if bagel not full | False | | ||
| | | | | | | ||
| | | | | | ||
|
|
||
| # 4. Member class | ||
|
|
||
| | Methods | Member variables | Scenario | Outputs/Results/Return values | | ||
| |---------------------------------------|-----------------------|-------------------|-------------------------------| | ||
| | basketCapacity(bagels ,bagelBasket[]) | String[] bagelsBasket | if basket full | increaseCapacity(); | | ||
| | increaseCapacity() | int capacity = 0; | if bagel not full | False | | ||
| | | | | | | ||
| | | | | | ||
|
|
||
| # 5. Member class | ||
|
|
||
| | Methods | Member variables | Scenario | Outputs/Results/Return values | | ||
| |------------------------------------|-----------------------|-------------------------|-------------------------------| | ||
| | removeBagel(bagels ,bagelBasket[]) | String[] bagelsBasket | if bagels exist | true | | ||
| | message() | | if bagel does not exist | False | | ||
| | | | | | | ||
| | | | | |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,48 @@ | ||
| package com.booleanuk.core; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public class Basket { | ||
| ArrayList<String> bagels; | ||
| int capacity = 2; | ||
| public Basket(){ | ||
| this.bagels = new ArrayList<>(capacity); | ||
| bagels.add("bagel2"); | ||
| } | ||
|
|
||
| public boolean addBagel(String bagel){ | ||
|
|
||
| if (bagels.contains(bagel)){ | ||
| return false; | ||
| } | ||
| bagels.add(bagel); | ||
| return true; | ||
| } | ||
| public boolean removeBagel(String bagel){ | ||
| if (bagels.contains(bagel)){ | ||
| bagels.remove(bagel); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| public boolean checkCapacity(){ | ||
| if (bagels.size() >capacity ){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public int updateCapacity(int newCap){ | ||
| this.capacity = newCap; | ||
| return this.capacity; | ||
| } | ||
| public String removeBagelString(String bagel){ | ||
| String ut="The bagel " + bagel + " doesn't exist"; | ||
| if (bagels.contains(bagel)){ | ||
| bagels.remove(bagel); | ||
| ut= "The bagel " + bagel + " is removed"; | ||
| } | ||
| return ut; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,6 +3,52 @@ | |
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class BasketTest { | ||
|
|
||
| public class BasketTest { | ||
|
|
||
| @Test | ||
| public void addSpecificBagelReturnTrue() { | ||
| Basket basket = new Basket(); | ||
|
|
||
| boolean result = basket.addBagel("bagel1"); | ||
| Assertions.assertTrue(result); | ||
| } | ||
|
|
||
| @Test | ||
| public void addSpecificBagelReturnFalse(){ | ||
| Basket basket = new Basket(); | ||
| boolean result = basket.addBagel("bagel2"); | ||
| Assertions.assertFalse(result); | ||
| } | ||
|
|
||
| @Test | ||
| public void removeSpecificBagelReturnTrue(){ | ||
| Basket basket = new Basket(); | ||
| boolean result = basket.removeBagel("bagel2"); | ||
| Assertions.assertTrue(result); | ||
| } | ||
|
|
||
| @Test | ||
| public void checkCapacityListReturnTrue(){ | ||
| Basket basket = new Basket(); | ||
| basket.addBagel("bagel3"); | ||
| basket.addBagel("bagel4"); | ||
| basket.addBagel("bagel5"); | ||
| basket.addBagel("bagel6"); | ||
| boolean result = basket.checkCapacity(); | ||
| Assertions.assertTrue(result); | ||
| } | ||
| @Test | ||
| public void updateCapacityReturnString(){ | ||
| Basket basket = new Basket(); | ||
| int updateCap=10; | ||
| String returnV = basket.removeBagelString("bagel10"); | ||
| Assertions.assertEquals("The bagel " + "bagel10" + " doesn't exist",returnV); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test appears to start off with the intention of updating the capacity but then ends up with code that tries to remove an non-existent bagel from the basket. |
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
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.
As I said in this morning's session it's best not to hard code example data into your code, do it in the tests instead.