Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
No random tests
There are a number of potential issues here:
DataGame
but the provided boilerplate saysGamesDetails
(should be singular,GameDetails
).stock
disappears.GameShop
class should probably receive its stock in the constructor rather than be hardcoded.shop
would be better-named asisCartWithinBudget
,canAffordCart
or similar.Cart
class with a contract like, for example,cart.isWithinBudget(budget)
and methods to add and remove items.GameShop
seems like too high a level of abstraction--that feels like the whole enterprise.import java.util.*
isn't considered good practice. Better to explicitly importHashMap
andList
(in that order, alphabetically).There are no tests where one would want to buy more items than available in stock: https://www.codewars.com/kata/reviews/634d800c238807000175778f/groups/634e7e6efb7a7d0001865f8c
Thanks for your comments, I have already changed some things that you were indeed right and I will continue improving the code
The casing of the games is very inconsistent ("Doom", "Halo", "Star Wars" vs. "lara croft", "call of duty") and different to the one given in initial solution setup (all lowercase).
Why does an empty shopping cart expect
false
? Surely I can buy all 0 games with any amount of money.Some coding style stuff:
List<String> l = new ArrayList<>();
. This is not Java 1.6.Random
classes withnextInt(bound)
. No need for JS-y(int)(Math.random()*1000 + 1)
.null
values? What is that even suppose to mean?yes, did I mention them in the statement?
In principle you have to be able to randomly add games to the cart and with random money in your pocket
thanks, I've noticed that I've put it wrong, it's already changed
thanks, I've noticed that I've put it wrong, it's already changed
Random tests perhaps?
Description mentions doom 4 times, but should mention the actual other games instead.
There are four different prices for "doom"? How does that work?