This file contains hidden or 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
# Ruby Fundamentals IV: Ruby Data Structures Assignment | |
characters = { | |
"Tyrion Lannister" => "House Lannister", | |
"Jon Snow" => "Night's Watch", | |
"Hodor" => "House Stark", | |
"Stannis Baratheon" => "House Baratheon", | |
"Theon Greyjoy" => "House Greyjoy" | |
} |
This file contains hidden or 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
# Alpha: Echo checkpoint (Phase 1) | |
def playback(input) | |
"You said: #{input}" | |
end | |
puts "What do you want to say?" | |
input = gets.chomp | |
puts playback(input) |
This file contains hidden or 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
# Alpha: Echo checkpoint (Phase 2) | |
def playback(input) | |
if input == "Nothing!" | |
"Ok, fine!" | |
elsif input == "I have a lot to say" | |
"I don't have time for that right now!" | |
else | |
"You said: #{input}" | |
end |
This file contains hidden or 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
# Alpha: Echo checkpoint (Phase 3) | |
def playback(input) | |
if input == "Nothing!" | |
"Ok, fine!" | |
elsif input == "I have a lot to say" | |
puts "Ok, let's hear it!" | |
multiline_output_from(gets_lines_of_input) | |
else | |
"You said: #{input}" |
This file contains hidden or 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
# Alpha: Echo checkpoint (Phase 4) | |
# METHODS | |
def playback(input) # This method is now way too long. Way to make it shorter? Or just move out of method into main program? | |
if input == "Nothing!" | |
"Ok, fine!" | |
elsif input == "I have a lot to say" | |
puts "Ok, let's hear it!" | |
multiline_output_from(gets_lines_of_input) |
This file contains hidden or 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
# Ruby Fundamentals 4: Challenge | |
require 'csv' | |
require 'date' | |
require 'table_print' | |
# DATA | |
products = [] | |
CSV.foreach('products.csv', headers: true) do |row| |
This file contains hidden or 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
# Ruby Fundamentals IV: Non-core Change Machine Kata | |
def is_valid_currency?(amount) | |
amount.to_s.match(/\A\d+[.]{0,1}\d{0,2}\z/) | |
end | |
amount_due = rand(0.0..100.0) | |
puts "Amount Due: #{sprintf("%.2f", amount_due)}\n\nWhat did customer supply?" | |
amount_tendered = gets.chomp.to_f |
This file contains hidden or 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
# OOP Fundamentals I: Assignment 1 | |
class Card | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
if rank.nil? |
This file contains hidden or 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
# OOP Fundamentals I: Assignment 2 | |
class Television | |
def initialize(brand, display_type, width, height) | |
@brand = brand | |
@display_type = display_type | |
@width = width | |
@height = height | |
end |
This file contains hidden or 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
# OOP Fundamentals I: Assignment 3 | |
class Car | |
def initialize(color, owner, cylinders) | |
@color = color | |
@owner = owner | |
@cylinders = cylinders | |
end | |
def color |