Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. /*
  2. * The Pokemart
  3. *
  4. * This assignment has you working with Objects and Functions/Methods.
  5. * The goal is to create code to represent a pokemart that sells items, and then
  6. * simulate a player purchasing some items from the pokemart.
  7. *
  8. * Requirements [READ CAREFULLY]:
  9. * The pokemart must be an Object containing at least 10 items. You can pick what
  10. * items are sold and at what price.
  11. * The player must have a predetermined amount of money, and must buy at least 20 items,
  12. * at least 3 of which must be unique (duplicates are allowed, make sure to give the player enough money).
  13. * Log how much money the player has to the console when the script starts.
  14. * Use an object to keep track of what is currently in the player's cart. Use functions/methods to add items to the cart.
  15. * Do NOT allow a player to have a negative number of an item in their cart.
  16. * Log when an item is added to the cart to the console, including the quantity.
  17. * The pokemart must have a checkout method to calculate how much money the player pays for the items.
  18. * The checkout method must log:
  19. * - A line for each item being purchased including the name of the item, quantity, and cost.
  20. * - A line for the total cost of the cart
  21. * - A line either saying how much money the player has left OR
  22. * - A line stating the player cannot afford the purchase
  23. * The checkout method must not allow a purchase that the player cannot afford.
  24. * OPTIONAL BONUS: Add an extra item that cannot be purchased but it can be obtained in a simaler way to premier balls in the pokemon games.
  25. * - If you do this, make sure this item cannot be added to the cart, and note how many were given (if > 0) after sucessfully checking out.
  26. * OPTIONAL BONUS 2: Make it so that the player can remove items from their cart. This can be a new function/method or built into
  27. * - the one for adding items to the cart (maybe a negative value indicates a removal?)
  28. * OPTIONAL BONUS 3: Empty the player's cart after they checkout (in the checkout function), and have them make a second purchase.
  29. * - (Second purchase only needs a total of 1 item and 1 unique item, unlike the first).
  30. *
  31. * HINTS:
  32. * DRY (Don't repeat yourself)
  33. * Try to make your code industrial strength. This means verify function arguments before doing what was asked.
  34. * For example: When adding to cart, make sure the requested item is a valid item & can be purchased, also make sure
  35. * the player will not have a negative number of that item in their cart after (or just block negative values).
  36. * You can use the return keyword to terminate a function early, even if the return value is unimportant to the function.
  37. * Use Math.floor(NUMBER) to round NUMBER down to the nearest whole number (returns an integer).
  38. */
  39. 'use strict';
  40.  
  41. // Your code here...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement