/club_ruby

[ruby, loops]

Primary LanguageRuby

Club Ruby

As the new manager of Club Ruby, you been tasked with creating an automated bouncing system.

The club's rules state:

  • Only people 18 and over are allowed in the door
  • No more than 8 people should be inside the club at any time

Using what you know about loops and collections in Ruby, write a script that when given an array of people waiting outside the club...:

  • Creates a new array of people inside the club
  • Allows the appropriate people into the club
  • Stops once 8 people have been admitted

Some sample people have been provided for you in script.rb.

Hint

  • How could you use next and break to alter the behavior of a loop?

Bonuses

  1. Determine whether or not a person can be served alcohol (that is: whether they're 21 or over)
  2. Create a new key/value pair for each person with served as a boolean
  3. Create an array for all people rejected from the club for being too young to enter