Skip to content

Instantly share code, notes, and snippets.

class Car
@@WHEELS = 4
def initialize(args)
@color = args[:color]
@wheels = @@WHEELS
end
def drive
@status = :driving
end
def brake
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
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]
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
# 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)
class RPNCalculator
def initialize
@arr
end
def evaluate string
@arr = string.split(" ")