It's approaching lunch hour… let's collect orders. Create a new file called lunch_orders.rb to complete this exercise.
- Create a program that collects lunch orders. Prompt:
- Name for order: (enter name)
- {name} wants to order: (enter item)
- Store the name/order data. When storing data, do it in such a way that additional order items may be added for the person's name.
- Example: Greg can order a Burger, and then add Fries to his order later.
- After storing data, prompt the user with:
- Add another item to the order? (y/n)
- Repeat steps 1 & 2 if the answer is "y"
- After the user completes adding orders, print out:
- "All orders: {order data}"
Rather than printing out a blob of raw lunch order data, print each name's orders on a separate line, formatted as one of the following:
- "Greg ordered a sandwich"
- "Peter ordered a burger & fries"
- "Travis ordered a salad, guac & water"
You may have to do some hunting in Ruby docs!
Game time! Create a new file called high_card.rb for this exercise.
Methods to research:
each_with_indexmax
Tasks:
- Build a deck of shuffled cards… maybe you can leverage some old code? Hint: you may want to add some additional card data!
- Collect an array of player names by prompting:
- "{n} players so far. Enter a player name, or type 'play':"
- Maybe you can leverage some old code here?
- Upon "play", deal each player a card.
- Find the highest card score dealt (Aces high).
- Find the winning player name, then print out:
- "Winner(s): {name1, name2, …}!"
Print out one of the following outcomes:
- "The winner is {name}!"
- "It's a tie between {name1, name2, …}!"
Now do it in Javascript.