Skip to content

Instantly share code, notes, and snippets.

@btforsythe
Last active January 12, 2019 19:04
Show Gist options
  • Save btforsythe/4411039e499ed5a3dbe4bae37b2a7b5e to your computer and use it in GitHub Desktop.
Save btforsythe/4411039e499ed5a3dbe4bae37b2a7b5e to your computer and use it in GitHub Desktop.
For practicing and understandings Maps
  1. Create a map for the restaurants menu with the menu items and prices for the items as entries. Your menu should include the following entries.
  • Spaghetti: $8.97
  • Lasagna: $10.98
  • Pizza: $15.50
  • Caesar Salad: $7.00
  • Kale Salad: $7.00
  1. Exploring the commonly used map methods:
  • A customer insists that their bill is incorrect and that the menu states that the spaghetti they ordered is priced at $7.97. Print the menu price of the spaghetti.
  • The restaurant owner is losing customers to the restaurant next door because customers want more menu options. Print the number of menu items, so the owner will know how many more she needs to add.
  • Use the put(key, value) method to add a "Bottle of Champagne" that costs "$200.00" to the menu and a "Bottle of Vintage Wine" that costs "$175.00" to the menu.
  • A prospective customer calls the restaurant because she's interested in planning a birthday dinner for her best friend. She is planning the budget and needs to know if they have a bottle of champagne that could be purchased for the table? Print the boolean response returned from the method that checks to see if a key exists.
  • The ink on a customer's bill smeared from a water spilled on the table. They can't tell if the bill says their item was $13.50 or $15.50. Print the boolean response returned from the method that will check to see if $13.50 is a price on the menu.
  • There's a been a recall on the all the fresh kale sourced for the restaurant due to a rare invasive fungus that could make customers ill. Remove "Kale Salad" from the menu.
  • The owner and chef have decided to do a complete revamp of the menu. Clear out the menu so all of the items and prices are removed so they can have a fresh start.
  • Before the chef and owner begin entering the new items and prices, they ask you to double check that all items were removed. Print the boolean response returned by the method that will check to see if the menu is clear.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment