Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save vanderhoop/e7d5dfe1b4292c8ed47c to your computer and use it in GitHub Desktop.

Select an option

Save vanderhoop/e7d5dfe1b4292c8ed47c to your computer and use it in GitHub Desktop.

While The Cradle Rocks

In today's "Classwork" directory, write a short Ruby program that tracks all the things Anastasia does while her son, Desmond, sleeps.

Directions

  1. Create a variable, desmond_is_sleeping and assign it the value of true
  2. Create a variable, anastasias_accomplishments and assign it an empty string ""
  3. Create a while loop that will run as long as Desmond is sleeping.
  4. As long as Desmond sleeps, ask Anastasia what errand she runs. Add it to the end of anastasias_accomplishments, along with a comma + space, as this should print as a string.
  5. Just before the end of the while loop, ask Anastasia if Desmond is still sleeping. Depending on her answer, assign desmond_is_sleeping to either true or false.
  6. After Desmond wakes up, print the value of anastasias_accomplishments to the console.

Bonus

Make it print in a sensible manner.

Example: While the Cradle Rocked, Anastasia built up her foundation in Ruby, took a nap herself, and went to the corner grocery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment