All files Busdriver.js

100% Statements 16/16
100% Branches 2/2
100% Functions 6/6
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38    56x 56x 56x 56x 56x 56x       56x 56x 56x       1x       126x       59x 59x     59x 6x   53x          
class Busdriver {
  constructor(driverProperties) {
    this.id = driverProperties.id;
    this.gossipArray = null;
    this.numberOfGossips = driverProperties.numberOfGossips;
    this.route = driverProperties.route;
    this.currentRouteIndex = 0;
    this.initialize();
  }
 
  initialize() {
    this.gossipArray = new Array(this.numberOfGossips);
    this.gossipArray.fill(false);
    this.gossipArray[this.id] = true;
  }
 
  getGossipArray() {
    return this.gossipArray;
  }
 
  getCurrentStation() {
    return this.route[this.currentRouteIndex];
  }
 
  driveToNextStation() {
    const isLastStop = () => {
      return this.currentRouteIndex === this.route.length - 1;
    };
 
    if (isLastStop()) {
      return this.currentRouteIndex = 0;
    }
    this.currentRouteIndex++;
  }
}
 
export default Busdriver;