Skip to content

Instantly share code, notes, and snippets.

@lgranger
Created September 28, 2015 00:21
Show Gist options
  • Save lgranger/bea113c422ca289e9c69 to your computer and use it in GitHub Desktop.
Save lgranger/bea113c422ca289e9c69 to your computer and use it in GitHub Desktop.
# Angry boss. Write an angry boss program that rudely asks you what you want. Whatever you answer, the angry boss should yell it back to you and then fire you.
puts "Huh? You again? What do you want!?"
want = gets.chomp.upcase
puts "WHAT?!!?!! YOU WANT \"#{want}\"!!??!! YOU'RE FIRED!!"
#Table of contents. Here's something for you to do in order to play around more with center, ljust, and rjust: write a program that will display a table of contents so that it looks like this:
page_width = 50
puts ("\"The Book Of Mad Skilz\"".center(page_width))
puts ("Table of Contents".center(page_width))
print ("Ch.1".ljust(page_width/3))
print ("What are Mad Skilz?".center(page_width/3))
puts ("Pg. 1".rjust(page_width/3))
print ("Ch.2".ljust(page_width/3))
print ("How do I get Mad Skilz?".center(page_width/3))
puts ("Pg. 26".rjust(page_width/3.75))
print ("Ch.3".ljust(page_width/3))
print ("Showing Off Your Mad Skilz".center(page_width/3))
puts ("Pg. 52".rjust(page_width/5))
@blip-lorist
Copy link

Mad skillz!

If you want to standardize your page_width formatting so that they're all page_width/3, you could increase the page_width. This could help it accommodate longer chapters.

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