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 | |
| @@WHEELS = 4 | |
| def initialize(args) | |
| @color = args[:color] | |
| @wheels = @@WHEELS | |
| end | |
| def drive | |
| @status = :driving | |
| end | |
| def brake |
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 Computer_Board | |
| attr_reader :board | |
| def initialize | |
| @ships = [%w[A A A A A], %w[B B B B], %w[C C C], %w[D D], %w[D D], %w[S S], %w[S S]] | |
| @board = Array.new(10) {Array.new(10,'/')} | |
| @mvmt = [ [-1, 0], #top | |
| [0, 1], #right |
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 Battleship | |
| attr_accessor :board | |
| def initialize | |
| @ships = [%w[A A A A A], %w[B B B B], %w[C C C]] | |
| @board = Array.new(10) {Array.new(10,'B')} | |
| @mvmt = [ [-1, 0], #top | |
| [0, 1], #right | |
| [1, 0], #bttm | |
| [0, -1]] #left | |
| @mvmt_words = %w[top right bttm left] |
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 Battleship | |
| attr_reader :board | |
| def initialize | |
| @ships = [%w[AC AC AC AC AC], %w[BS BS BS BS], %w[CR CR CR], %w[DS DS], %w[SB SB]] | |
| @board = Array.new(10) {Array.new(10,'/')} | |
| @mvmt = [ [-1, 0], #top | |
| [0, 1], #right | |
| [1, 0], #bttm | |
| [0, -1]] #left | |
| 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
| # Save this file to your computer so you can run it | |
| # via the command line (Terminal) like so: | |
| # $ ruby deaf_grandma.rb | |
| # | |
| # Your method should wait for user input, which corresponds | |
| # to you saying something to your Grandma. | |
| # You'll probably want to write other methods, but this | |
| # encapsulates the core Grandma logic | |
| def walk_away(answer) |
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 RPNCalculator | |
| def initialize | |
| @arr | |
| end | |
| def evaluate string | |
| @arr = string.split(" ") | |