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
//------------------------------------------------------------------------------------------------------------------ | |
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here. | |
//------------------------------------------------------------------------------------------------------------------ | |
//------------------------------------------------------------------------------------------------------------------ | |
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work. | |
//------------------------------------------------------------------------------------------------------------------ |
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 'rspec' | |
require_relative '../assessment_week2' | |
describe Vehicle do | |
subject { Vehicle.new(Hash[color: "black", wheels: 2]) } | |
it { should be_instance_of Vehicle } | |
its (:wheels) { should == 2 } |
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
http://prendan.com/EssntlHandOuts/00aaPrepositionQuickListUpdated.pdf |
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
/[\]\[!"#$%&'()*+,./:;<=>?@\^_`{|}~-]/ |
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
def convert_to_english(num) | |
word_hash = { | |
1 => "one", | |
2 => "two", | |
3 => "three", | |
4 => "four", | |
5 => "five", | |
6 => "six", | |
7 => "seven", | |
8 => "eight", |
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
def times_table(rows) | |
# Your code here! | |
column_count = 0 | |
row_count = 1 | |
output = 0 | |
results = [] | |
answer = 0 | |
(rows).times do | |
(rows).times do | |
column_count += 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
class RPNCalculator | |
def evaluate(string) | |
string_array = string.split(" ") | |
queue_array = [] | |
calculations = [] | |
string_array.each do |element| | |
if (element.match /[A-Za-z0-9_.]/) | |
queue_array.push(element) | |
else | |
calculations = queue_array.slice!(queue_array.length-2,2) |
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
# Determine whether a string contains a Social Security number. | |
def has_ssn?(string) | |
output = string.match(/\d{3}-\d{2}-\d{4}/) | |
end | |
# Return the Social Security number from a string. | |
def grab_ssn(string) | |
if string.match(/\d{3}-\d{2}-\d{4}/) | |
match1 = string.match(/\d{3}-\d{2}-\d{4}/) | |
match1.to_s |
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 GuessingGame | |
def initialize(guess) | |
@guess = guess | |
end | |
def guess(attempt) | |
if attempt > @guess | |
@correctanswer = 'correct' | |
return :high | |
elsif attempt == @guess |
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 Array | |
def pad!(min_size, value = nil) | |
if self.length >= min_size | |
return self | |
else | |
add_amount = (self.length - min_size) | |
add_amount.times {self.push(value)} |