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 "pry" | |
| ##!/usr/bin/env ruby | |
| ## encoding: UTF-8 | |
| SUITS = ['♠', '♣', '♥', '♦'] | |
| VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] | |
| def build_deck | |
| deck = [] |
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
| # Quick Challenge | |
| 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
| class Channel | |
| attr_accessor :channel_number | |
| def initialize(channel_number) | |
| @channel_number = channel_number | |
| end | |
| def change_channel(channel_number) | |
| puts "You are changing channels" | |
| @channel_number = channel_number | |
| 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 Car | |
| def initialize(color, owner, cylinders) | |
| @color = color | |
| @owner = owner | |
| @cylinders = cylinders | |
| end | |
| def color | |
| @color | |
| 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 Card | |
| def initialize(rank, suit) | |
| @suit = suit | |
| @rank = rank | |
| end | |
| def rank | |
| @rank | |
| 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 Whiteboard | |
| attr_accessor :contents | |
| def initialize(contents = []) | |
| @contents = contents | |
| end | |
| def dry_marker_eraser | |
| @contents = [] | |
| 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 FinalGrade | |
| attr_reader :student, :avg | |
| def initialize(argument) | |
| @avg = argument[:avg] | |
| @student = argument[:student] | |
| end | |
| def letter_grade | |
| return "A" if @avg >= 90 | |
| return "B" if @avg >= 80 && @avg < 90 |
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
| # Implement your solution here. You may reference any additional files from here as well. | |
| def phase_2 | |
| puts "What was team 1's name?" | |
| team1 = gets.chomp | |
| puts "What was team 1's score?" | |
| t1score = gets.chomp.to_i | |
| puts "What was team 2's name?" | |
| team2 = gets.chomp |
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
| # Implement your solution here. You may reference any additional files from here as well. | |
| TEAMS = (1..2).to_a | |
| def questioner(question) | |
| puts question + "?" | |
| input = gets.chomp | |
| end | |
| def team_checker(name, hash) | |
| hash.keys.include?(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
| class Circle | |
| def initialize(radius) | |
| @radius = radius | |
| @pi = 3.14159265359 | |
| end | |
| def diameter | |
| @radius * 2 | |
| end |