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
#######################################PSEUDOCODE################################### | |
# INPUT, OUTPUT & PSEUDOCODE: | |
# Initialize => INPUT: number of sides = integer > 0 | |
# OUTPUT: new Die object | |
# # set instance variable sides to value of passed argument | |
# Die#sides => INPUT: none | |
# OUTPUT: number of sides | |
# getter/accessor method for sides | |
# Die#roll => INPUT: none |
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
#######################################PSEUDOCODE################################### | |
# INPUT, OUTPUT & PSEUDOCODE: | |
# Initialize => INPUT: array of strings (labels) | |
# OUTPUT: new Die object | |
# a. raises argument error if passed an empty array | |
# b. Creates instance variabel for labels | |
# Die#sides => INPUT: none | |
# OUTPUT: number of sides | |
# a. calculate and return size of labels array |
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
####################################### PSEUDOCODE ##################################### | |
# INPUT: initialize a game passing the correct integer answer to instantiate; | |
# pass a guess value to #guess | |
# OUPUT: #guess outputs symbol representing | |
# if the most recent guess is too high, too low, or correct | |
# #solved? outputs true if the most recent guess is correct and flase otherwise. | |
# STEPS: #initialize -> set answer to instance variable, answer | |
#guess -> return corresponding symbol for too high, too low, correct |
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
####################################### PSEUDOCODE ##################################### | |
# INPUT: Initialize object with input 16-digit integer parameter | |
# OUPUT: #initialize outputs invalid ArgumentError for input integers not 16 digits | |
# #CreditCard#check_card outputs boolean true/false for | |
# valid/invalid digits as credit card number | |
# STEPS: #initialize raise ArgumentError if input parameter is not 16 digits | |
# set input to instance variable for card number | |
#card_number isolate digits to double and multiply them by 2 |
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
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'net/http' | |
require 'iconv' | |
require 'optparse' | |
require 'fileutils' | |
require 'cgi' | |
$options = {} |
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 Drawer | |
#don't need attribute reader for content at this point | |
def initialize | |
@contents = [] | |
@open = true | |
end | |
def open | |
@open = true |
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
# OBJECTIVE 3: CREATE PEZ CLASS | |
# See objectives #1, #2, and #6 after #3 | |
class PezDispenser | |
@@available_flavors = %w(cherry chocolate cola grape lemon orange peppermint raspberry strawberry raspberry-lemon strawberry-vanilla) | |
# Class variable describes current market available pez flavors (wikipedia; exclues sugarfree & sour) | |
def initialize(flavors) | |
unless flavors == flavors.select { |flavor| valid_flavor?(flavor) } | |
raise ArgumentError.new('Contains invalid flavors') # raises if input includes invalid flavor | |
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 BoggleBoard | |
def initialize(dice_grid) | |
@dice_grid = dice_grid | |
end | |
def create_word(*coords) | |
coords.map { |coord| @dice_grid[coord.first][coord.last]}.join('') | |
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
require 'sqlite3' | |
$db = SQLite3::Database.open 'congress_poll_results.db' | |
def print_arizona_reps | |
puts 'AZ REPRESENTATIVES' | |
az_reps = $db.execute("SELECT name FROM congress_members WHERE location = 'AZ'") | |
az_reps.each { |rep| puts rep } | |
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
# REVIEWING ASSERT STATEMENT | |
# --------- | |
def assert | |
raise "Assertion failed!" unless yield | |
end | |
name = "bettysue" | |
assert { name == "bettysue" } | |
assert { name == "billybob" } |