Code Monkey home page Code Monkey logo

jv-robot's Introduction

jv-robot


Task Requirement

We have our good friend Robot Johny who got lost on the playground. His position is represented by two integer coordinates: X and Y. X is the horizontal axis and Y is the vertical axis. Unfortunately, he has some unknown random initial position and we don't even know the initial Direction in which he is facing. But he really wants to go home, which is represented by toX and toY.

Your task is to help Johny find his way home by implementing logic in the RobotRoute class that navigates the robot from its current position to the target position.

Provided Classes

Direction Enum

An enum named Direction is provided which has the following values: UP, DOWN, LEFT, and RIGHT.

Robot Class

The Robot class is provided with the following methods:

  • getDirection(): returns the current direction of the robot.
  • getX() and getY(): return the current X and Y coordinates of the robot respectively.
  • turnLeft() and turnRight(): change the direction of the robot to the left or right respectively.
  • stepForward(): moves the robot one step forward in its current direction.

RobotRoute Class

The RobotRoute class is provided with a method signature:

  • moveRobot(Robot robot, int toX, int toY): This method should take a Robot instance and two integer parameters toX and toY, which represent the target position. The method should navigate the robot from its current position to the target position, considering its current direction and updating its direction as needed.

Requirements

  • Implement the logic in the moveRobot method of the RobotRoute class to navigate the robot from its current position to the target position (toX, toY).
  • The robot should be able to navigate through all four quadrants of the coordinate plane.
  • The robot should be able to handle moving from any quadrant to any other quadrant, as well as staying in the same position.
  • The robot's position and direction should be updated appropriately after the moveRobot method is called.

Notes

jv-robot's People

Contributors

boroda4436 avatar kseniiamakarova avatar nacenik avatar nick97-git avatar romandubovskyi avatar sofasmile avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.