Sha256: ef7af2efafebe8f9e95f66ff39508809a510716cef17e3b7bc0b2617c60afe51

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

module Robot
  class Game
    attr_reader :input

    def initialize(input: $stdin)
      @input = input
    end

    def simulate
      while command = input.gets
        command = command.chomp
        @position = Robot::CommandProxy.new(command_string: command, position: @position).call
      end
    end

    def self.call(input: $stdin)
      game = new(input: input)
      instruction
      game.simulate
    end

    def self.instruction
      puts  <<~HEREDOC
        Welcome to the Robot game
        Please enter one of the following commands:
        PLACE 0,0,NORTH (PLACE X,Y,DIRECTION)
        MOVE
        LEFT
        RIGHT
        REPORT

        invalid commands are ignored.
        You must start with a place command.
      HEREDOC
    end
  end
end



Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
robot_rea-0.1.5 lib/robot/game.rb