Instantiate an object of a class inside the constructor of another class

0

[SOLVED] How do I instantiate the Mars object within the Rover class? Well, I'm returning the following error: "Mars is not defined"

class Rover{

  constructor(orderedX,orderedY,orientation,toMove){
    this.orderedX = orderedX;
    this.orderedY = orderedY;
    this.orientation = orientation;
    this.toMove = toMove;
    this.marsZise = new Mars(5,5);
    this.running();

  }

class Mars{
  constructor(sizeX,sizeY){
    this._orderedlengthX = sizeX;
    this._orderedlengthY = sizeY;

  }
    
asked by anonymous 19.02.2018 / 15:48

1 answer

0

So I noticed, you're using typescript , to inherit classe , just use extends as follows:

Rover extends Mars
    
19.02.2018 / 16:07