Guest User

Untitled

a guest
Feb 5th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Vehicle (speed,weight, manufacturer, isMilitary) {
  2.   this.speed = speed; // Средняя скорость, км/ч
  3.   this.weight = weight; // Вес транспорта, кг
  4.   this.manufacturer = manufacturer; // Страна-производитель данной техники
  5.   this.isMilitary = isMilitary || false; // Данная техника военная? - false по умолчанию
  6.  
  7.   this.getSpecifications = function () {
  8.     this.isMilitary ? this.isMilitary = 'Да' : this.isMilitary = 'Нет';
  9.    
  10.     console.log (
  11.       `Основные характеристики:
  12.        Средняя скорость: ${this.speed} км/ч;
  13.        Вес: ${this.weight} кг;
  14.        Страна-производитель: ${this.manufacturer};
  15.        Военная техника: ${this.isMilitary}.
  16.       `
  17.     )
  18.   }
  19. }
  20.  
  21. // ===
  22.  
  23. function Auto (model, color, fuel, transmission) {
  24.   Vehicle.apply(this, arguments)
  25.  
  26.   this.model = model; // Модель автомобиля
  27.   this.color = color; // Цвет автомобиля
  28.   this.fuel = fuel; // Тип топлива (бензин, дизель)
  29.   this.transmission = transmission;  // Коробка передач (механическая, автоматическая)
  30. }
  31.  
  32. let toyota = new Auto (100, 3500, 'Japan', false, 'Toyota', 'white', 'petrol', 'automatic');
Advertisement
Add Comment
Please, Sign In to add comment