GithubHelp home page GithubHelp logo

elizabeth-honch / js_robot_factory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liudmylailchenko/js_robot_factory

0.0 0.0 0.0 81 KB

License: GNU General Public License v3.0

JavaScript 100.00%

js_robot_factory's Introduction

Robot factory

Let's consolidate our knowledge of prototypes and constructors! This task has 3 parts.

The first part is to build base robot's constructor and its prototype according to the following requirements:

  • BaseRobot function constructor takes name, weight, coords, chipVersion and sets them for his instances;
  • BaseRobot prototype has methods goForward, goBack, goRight, goLeft, which can take step prop or move the robot by 1 in the appropriate direction in the case when step is undefined;
  • BaseRobot prototype has method getInfo, which returns a string in the format Robot: %name%, Chip version: %chipVersion%, Weight: %weight%;

The second part is to build flying robots constructor and his prototype according to the following requirements:

  • FlyingRobot prototype inherits BaseRobot prototype;
  • FlyingRobot constructor takes name, weight, coords, chipVersion, and transmits them to BaseRobot constructor;
  • FlyingRobot constructor sets z coordinate to coords object of his instances;
  • FlyingRobot prototype has methods goUp and goDown, which can take step prop or move the robot by 1 in the z coordinate in the case when step is undefined;
  • The instance of FlyingRobot can use all methods from BaseRobot and FlyingRobot prototypes;

The third part is to build delivery drone constructor and his prototype according to the following requirements:

  • DeliveryDrone prototype inherits FlyingRobot prototype;
  • DeliveryDrone constructor takes name, weight, coords, chipVersion, and transmits them to FlyingRobot constructor;
  • DeliveryDrone constructor takes maxLoadWeight, currentLoad and sets it to his instances;
  • DeliveryDrone prototype has method hookLoad, which saved the load object to currentLoad of DeliveryDrone instances if weight of cargo less than maxLoadWeight of drone;
  • DeliveryDrone prototype has method unhookLoad, which sets initial value null to currentLoad;
  • The instance of DeliveryDrone can use all methods of BaseRobot, FlyingRobot, DeliveryDrone prototypes;

Delivery Robot schema:

deliveryRobot {
  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 elizabeth-honch avatar mgrinko 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.