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
class Triangle | |
attr_accessor :s1, :s2, :s3 | |
def initialize(s1, s2, s3) | |
@s1 = s1 | |
@s2 = s2 | |
@s3 = s3 | |
end | |
def kind |
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
# Using Nested Hashes, define a game, with two teams, their players, and the players stats: | |
# The game has two teams. | |
# A team has: | |
# A name | |
# Two colors | |
# Each team should have at least 5 players | |
# Each player should have a: | |
# name |
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
require 'simplecov' | |
SimpleCov.start | |
require 'json' | |
require 'rspec' | |
require_relative 'jukebox' | |
require_relative 'song' | |
#use this song data for your tests | |
songs = [ |
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
class School | |
attr_accessor :roster, :name, :grade | |
def initialize(name) | |
@name = name | |
@roster = {} | |
end | |
def add_student(student_name, grade) | |
@roster[grade] ||= [] |
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
code |
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
require_relative './song_library.rb' | |
def jukebox(command) | |
if command.downcase == "list" | |
list_library | |
else | |
parse_command(command) | |
end | |
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
class Anagram | |
attr_accessor :word | |
def initialize(word) | |
@word = word | |
end | |
def match(array) | |
@word = @word.chars.sort | |
array.select { |element| element.chars.sort == @word } |
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
######################## | |
# NYC PIGEON ORGANIZER # | |
######################## | |
pigeon_data = { | |
:color => { | |
:purple => ["Theo", "Peter Jr.", "Lucky"], | |
:grey => ["Theo", "Peter Jr.", "Ms .K"], | |
:white => ["Queenie", "Andrew", "Ms .K", "Alex"], | |
:brown => ["Queenie", "Alex"] |
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
# A movie collection that organizes by genres | |
# Recipes with ingredients | |
# User profiles where each user has a list of favorite colors along | |
# with 3 personal essays, essay_1, essay_2, essay_3 | |
movie_collection = { | |
:comedy => ["Dumb and Dumber", "Billy Madison", "American Pie"], | |
:action_adventure => ["Indiana Jones", "Die Hard", "Terminator"], | |
:documentary => ["Man on a Wire", "Exit Through the Gift Shop"] | |
} |
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
=begin | |
Let's go back to the exercise where we determined what | |
is and isn't a vowel. With ruby, there's always more than | |
one way to do something and get the same result. | |
Assuming vowels a,e,i,o,u: | |
#1 Write a method that returns whether a given letter is a vowel, | |
using if and elsif |