Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Tarcaye
Copy link
Owner

@Tarcaye Tarcaye commented Dec 2, 2019

No description provided.

@Tarcaye Tarcaye force-pushed the feature/basket-informations branch 2 times, most recently from ee7b8f0 to e5d5fe5 Compare December 2, 2019 13:15
@Tarcaye Tarcaye force-pushed the feature/basket-informations branch from e5d5fe5 to 3f5b798 Compare December 2, 2019 13:16
@Tarcaye Tarcaye changed the title Add BasketInformations [Java] Add BasketInformations Jan 24, 2022
Copy link

@dpassi dpassi left a 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>();

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) {

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;

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) {

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()) {

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;

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants