-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Java] Add BasketInformations #1
base: master
Are you sure you want to change the base?
Conversation
ee7b8f0
to
e5d5fe5
Compare
e5d5fe5
to
3f5b798
Compare
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.
.
public class BasketInformations { | ||
|
||
// The product of the basket | ||
static HashMap<String, Integer> map = new HashMap<String, Integer>(); |
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.
Naming can be better, what is this a map of?
// The fact that the basket has promo code | ||
private static boolean codeDePromotion = false; | ||
|
||
public void addProductToBasket(String product, Integer price, boolean isPromoCode) { |
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.
price better be double to accomodate decimals.
|
||
public void addProductToBasket(String product, Integer price, boolean isPromoCode) { | ||
if (isPromoCode) { | ||
codeDePromotion = true; |
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.
should we convey to callers that adding to basket failed or was not done?
map.clear(); | ||
} | ||
|
||
public boolean isBasketContains(String produit) { |
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.
spell check, produit -> product?
|
||
public boolean isBasketContains(String produit) { | ||
boolean found = false; | ||
for (String s : map.keySet()) { |
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.
why not directly do map,get ?
public boolean isBasketContains(String produit) { | ||
boolean found = false; | ||
for (String s : map.keySet()) { | ||
if (s == produit) found = true; |
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.
return true if found, dont need to continue the loop.
No description provided.