Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ruby Mini-Assignment 1 by DSH
- # Due Saturday, December 28th, 2013
- # OOP isn't really needed for this assignment.
- # I tried to force this assignment into using it so I could be more confortable with OOP in Ruby, though.
- #Table of contents - only makes sense that this goes at the beginning, even though it's technically Part IV
- puts "Table of contents"
- print "Part I"
- puts "Time stuff".center(38)
- print "Part II"
- puts "Name/Favorite Number".rjust(33)
- print "Part III".ljust(20)
- puts "Angry boss"
- #Part 1
- class PartOne
- def hoursInAYear
- hours = 365.25*24
- return hours
- end
- def minutesInADecade
- minutes = 10*365.25*24*60
- return minutes
- end
- def yearsOldToSecondsOld(years)
- seconds = years*365.24*60*60
- return seconds
- end
- end
- puts "\nPart One"
- partOne = PartOne.new
- puts "PART I: Hours in a year/Minutes in a decade/Seconds in your life"
- puts "How many hours are in a year? Exactly " + partOne.hoursInAYear.to_s
- puts "How many minutes in a decade? Exactly " + partOne.minutesInADecade.to_s
- print "How many years old are you? "
- userYearsOld = gets.chomp.to_i
- puts "That means you are " + partOne.yearsOldToSecondsOld(userYearsOld).to_s + " seconds old!"
- #Part 2
- class PartTwo
- def greetUserWithFullName(first, middle, last)
- return "Hello, " + first + " " + middle + " " + last + "! You're looking sexy today!"
- end
- def oneUpFavoriteNumber(favoriteNumber)
- return "I think that your favorite number should be " + (favoriteNumber+1).to_s + "! It's much better, don't you agree?"
- end
- end
- partTwo = PartTwo.new
- puts "\nPART II: Name/Favorite Number"
- print "What is your first name? "
- firstName = gets.chomp
- print "What is your middle name? "
- middleName = gets.chomp
- print "What is your last name? "
- lastName = gets.chomp
- puts partTwo.greetUserWithFullName(firstName, middleName, lastName)
- print "What is your favorite number? "
- favoriteNumber = gets.chomp
- puts partTwo.oneUpFavoriteNumber(favoriteNumber.to_i)
- #Part 3
- #Too lazy to make a class for this, sorry
- puts "\nPart III: Angry boss"
- puts "What do you want, " + firstName + "? I'm busy."
- request = gets.chomp
- puts "WHAT DO YOU MEAN \""+request+"\"?! YOU'RE FIRED!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement