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
| var num = Math.floor((Math.random() * 100) + 1); | |
| var name = prompt("What's your name?"); | |
| var guess = null; | |
| while (guess != num) { | |
| var guess = prompt(name + ", enter a guess, between 1 and 100 (or enter Q to quit)."); | |
| if (guess > num) { | |
| alert("Too high!"); |
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' | |
| class Minefield | |
| attr_reader :row_count, :column_count | |
| def initialize(row_count, column_count, mine_count) | |
| @column_count = column_count | |
| @row_count = row_count | |
| @empty_cells = (column_count * row_count) - mine_count | |
| @clear_count = 0 |
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 Deck | |
| def initialize | |
| @collection = [] | |
| # Fill deck with cards, SUITS * VALUES | |
| Card::SUITS.each do |suit| | |
| Card::VALUES.each do |value| | |
| @collection << Card.new(value, suit) |
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 Mortgage | |
| def initialize(home_value, down_payment_percentage, apr, duration_in_years) | |
| @home_value = home_value | |
| @down_payment_percentage = down_payment_percentage | |
| @apr = apr | |
| @duration_in_years = duration_in_years | |
| end | |
| def down_payment | |
| @down_payment = @home_value * @down_payment_percentage |
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 erase | |
| @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 Whiteboard | |
| attr_accessor :contents | |
| def initialize(contents = []) | |
| @contents = contents | |
| end | |
| def erase | |
| @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 Card | |
| def initialize(rank, suit) | |
| @suit = suit | |
| @rank = rank | |
| end | |
| def suit | |
| @suit | |
| 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 Television | |
| def initialize(screen_size,type,brand) | |
| @screen_size = screen_size | |
| @type = type | |
| @brand = brand | |
| 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 Card | |
| def initialize(rank = nil, suit = nil) | |
| if suit.nil? | |
| @suit = ['♠', '♣', '♥', '♦'].sample | |
| else | |
| @suit = suit | |
| end | |
| if rank.nil? | |
| @rank = ['1','2','3','4','5','6','7','8','9'].sample | |
| else |
NewerOlder