This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hours in a year, minutes in a decade, my age in seconds, author's age. | |
require 'date' | |
class DatesAndtimes | |
attr_reader :minute, :day, :year, :now, :seconds, :age, :result | |
def initialize | |
@seconds = 60 | |
@minute = 60 | |
@day = 24 | |
@year = 365.242 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# screencast #2 b = 1 - bc var a and bar or diff objects with diff objects_id's | |
# screencast #2 x = 2 bc 1 plus 1 equals 2 (the value of x was changed by adding 1 to it) | |
# below you will find chapter 5 | |
# => ask the user for a their frist name | |
# => ask the user for their middle name | |
# => ask the user for their last name | |
# => output, nice to meet you 'their name' | |
# => ask the user for their favorit number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#screencast #3 - Not really sure if I did this right. I have never asked for the class of a class of a string | |
1 => float | |
2 => String | |
3 => Range | |
4 => Class | |
5 => Class?? like I said wasn't sure what to do here, "hello".class.class is class, "hello".class is String | |
#screencast #4, very cool method, not sure when one would use this but I did read that it was faster then downcase | |
#Method number 1 | |
"Troy" == "troy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# => 100 bottles of beer on the wall | |
# => 100 bottles of beer | |
# => take on down, pass it around | |
# => 99 bottles of beer on the wall | |
# => | |
# => 99 bottles of beer on the wall | |
# => 99 bottels of beer | |
# => take on down, pass it around |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Grandma | |
def talk | |
bye_counter = 0 | |
puts "Lets have a talk with Grandma" | |
puts "Grandma is hard of hearing so you might have to SHOUT when you talk" | |
puts "To leave Grandma's place you have to type BYE 3 times..." | |
print "What would you like to say to grandma? " | |
while true | |
input = gets.chomp | |
if input == input.upcase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'leap_year' | |
class Display | |
def single_year | |
puts "Sometimes it would be nice to know if a particular year was a leap year" | |
print "What year would you like to know if it was OR will be a leap year?: " | |
input = gets.chomp | |
answer = SingleLeapYear.new(input) | |
answer.leap_year? | |
answer.display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LeapYearRange | |
attr_reader :years, :leap_years | |
def initialize(years) | |
@years = years | |
@leap_years = [] | |
end | |
def leap_year? | |
years.each do |date| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#At the bottom of this file you will find a utilities file that I put together for such things as | |
#lines and clear screen function!! | |
#I am working on the last screen cast with the answer the 3 question bit! sorry it isn't done! | |
require_relative 'bottles_beer' | |
require_relative 'deaf_grandma' | |
require_relative 'leap_display' | |
require_relative 'runner_utili' | |
reset_screen! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_number = rand(50) | |
num_guesses = 0 | |
loop { | |
print "choose a number between 1 and 6: " | |
guess = gets.chomp.to_i | |
num_guesses += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10.downto(0) do |number| | |
puts number | |
end | |
puts "BLASTOFF!" |
OlderNewer