U E D R , A S I H C RSS

정모/2011.4.4/Code Race/김수경

River Crossing

  • 2011 4 4 CodeRace. CodeRace . . 3 .
  • RubyLanguage
  • TDD rake aborted! No Rakefile found. 함. 한 . ㅜㅜㅜㅜㅜㅜ
  • ... .

  • A B .

  • A B .
  • .

Step 1

  • A B .

class Layton
  @location
  attr_accessor :location

  def initialize
    @location = false
  end

  def crossRiver
    @location = true
  end
end
layton = Layton.new()
layton.crossRiver

if !layton.location
  print "FAIL"
end

Step 2

  • .
    • A -> B
    • B -> A

class Layton
  @location
  attr_accessor :location

  def initialize
    @location = false
  end

  def crossRiver
    @location = !@location
  end
end
class Solver
  def run(person)
    person.crossRiver
  end
end
solver = Solver.new()
layton = Layton.new()
solver.run(layton)

if !layton.location
  print "FAIL"
end

Step 3


    • .

Step 4


    • .

Step 5

  • 2 .
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:51
Processing time 0.0140 sec