WZYCX / RSStodge-STUDENT

Files for Rugby School Stodge Application
2 stars 0 forks source link

you can add two of same item into basket #17

Closed WZYCX closed 1 year ago

WZYCX commented 2 years ago

If you add an item already in basket, it should just add one more not duplicated

Maybe display 'added' on menu page or show the 'iteminbasket' on menu page

WZYCX commented 1 year ago

Fixed! ' var inBasket = false for purchased in basket.currentBasket { if (item.name == purchased.name) { //if item exists in basket already +=1 else add new item inBasket = true break } } if inBasket==false { item.count+=1 basket.currentBasket.append(item) print(basket.currentBasket) basket.calculateCost() //updates basket total cost value print("Added item") } else { print("Already in Basket") } ' does not allow items to be added in twice

WZYCX commented 1 year ago

edit 'ELSE' to add +1 to quantity

WZYCX commented 1 year ago

COMPLETED and the 'count' incrementation is under a different issue