Giter Site home page Giter Site logo

js_robot_factory's Introduction

Robot factory

Let's implement 3 classes with inheritance

BaseRobot

  • constructor takes name, weight, coords, chipVersion and saves them
  • coords should be set to 0 if not passed
  • goForward, goBack, goRight and goLeft methods take a step argument (1 by default) and move the robot by step in the appropriate direction
  • getInfo method returns a string in the next format Robot: %name%, Chip version: %chipVersion%, Weight: %weight%

FlyingRobot

  • inherits all the methods from BaseRobot
  • takes the same args as BaseRobot and passes them to the parent's constructor
  • can work with z coords
  • has methods goUp and goDown changing z coordinate by a given step

DeliveryDrone

  • inherits all the methods from FlyingRobot and calls its constructor
  • in addition to FlyingRobot's args it takes maxLoadWeight and currentLoad and saves them.
  • has hookLoad method taking a cargo object and saving it to a currentLoad property if it is empty and the cargo.weight is not greater than the maxLoadWeight of the drone.
  • if the drone already has currentLoad do not change it
  • has unhookLoad method, that currentLoad property to null
DeliveryDrone {
  name: string
  weight: number
  chipVersion: number
  maxLoadWeight: number
  currentLoad: null || {
    weight: number
    description: string
  }
  coords: {
    x: number
    y: number
    z: number
  }
}

Read the guideline before start

js_robot_factory's People

Contributors

danheim avatar denys-cheporniuk avatar ibrianwarner avatar mgrinko avatar solaryasha avatar vpolets 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.