Ad
  • Custom User Avatar
  • Custom User Avatar

    There are a number of potential issues here:

    • Description says DataGame but the provided boilerplate says GamesDetails (should be singular, GameDetails).
    • It's unclear why the stock is part of the instructions if it's supposed to be ignored.
    • There's not much motivation for the class since it's just a String -> Integer mapping after stock disappears.
    • The GameShop class should probably receive its stock in the constructor rather than be hardcoded.
    • The method shop would be better-named as isCartWithinBudget, canAffordCart or similar.
    • This method should probably belong to a 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.
    • Prices generally shouldn't be represented as floats due to precision issues.
    • It seems like poor design to be converting string names to objects in the first place--normally, strings would be deserialized directly into classes, or they'd be properties on objects.
    • Typo "porpuse" -> "purpose".
    • "And thirdly the porpuse of your kata is to when a client has enough budget to buy the games he desires." is not a sentence.
    • I believe import java.util.* isn't considered good practice. Better to explicitly import HashMap and List (in that order, alphabetically).
  • Custom User Avatar

    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

  • Default User Avatar

    Thanks for your comments, I have already changed some things that you were indeed right and I will continue improving the code

  • Custom User Avatar

    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:

    • Use the diamond operator List<String> l = new ArrayList<>();. This is not Java 1.6.
    • Please have a consistent code indentation.
    • Java has proper Random classes with nextInt(bound). No need for JS-y (int)(Math.random()*1000 + 1).
    • Why can the shopping cart contain null values? What is that even suppose to mean?
  • Default User Avatar

    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

  • Default User Avatar

    thanks, I've noticed that I've put it wrong, it's already changed

  • Default User Avatar

    thanks, I've noticed that I've put it wrong, it's already changed

  • Custom User Avatar

    Random tests perhaps?

  • Custom User Avatar

    Description mentions doom 4 times, but should mention the actual other games instead.

  • Custom User Avatar
    Your collection should look like this: "doom", (59.99, 5) "call of duty", (42.99, 10) "doom", (10.00, 20) "doom", (4.99, 2) "doom", (16.00, 50)
    

    There are four different prices for "doom"? How does that work?