Добавил функции getInfo, вывел информацию в консоль

related #2
parent f035f9cc
...@@ -21,4 +21,12 @@ export class Truck { ...@@ -21,4 +21,12 @@ export class Truck {
changeState (state: TruckState) { changeState (state: TruckState) {
this._state = state; this._state = state;
}; };
getInfoAll (): void {
console.log(`${this.id} | ${this.name} | ${this.driver.name} | ${this._state.name}`);
};
getInfoSolo (): void {
console.log(`Айди: ${this.id} \nГрузовик: ${this.name} \nВодитель: ${this.driver.name} \nСостояние: ${this._state.name}`);
};
}; };
\ No newline at end of file
...@@ -9,4 +9,12 @@ const renault = new Truck(1, "Renault Magnum", john); ...@@ -9,4 +9,12 @@ const renault = new Truck(1, "Renault Magnum", john);
const volvo = new Truck(2, "Volvo FH12", jack); const volvo = new Truck(2, "Volvo FH12", jack);
const daf = new Truck(3, "DAF XF", jane); const daf = new Truck(3, "DAF XF", jane);
const trucks: Truck[] = [renault, volvo, daf]; const trucks: Truck[] = [renault, volvo, daf];
\ No newline at end of file
function getTrucksIngo (truks: Truck[]): void {
console.log('№ | Грузовик | Водитель | Состояние');
for (let i = 0; i < trucks.length; i++) {
trucks[i].getInfoAll();
};
};
getTrucksIngo(trucks);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment