-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.ts
34 lines (28 loc) · 1.01 KB
/
class.ts
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
// Create a function that takes this value as its parameter and simply print the properties.
class Vehicle {
protected model : string;
protected color : string;
protected yearOfManufacture :number;
constructor(Model : string, Shade : string, Year : number ) {
this.model = Model;
this.color = Shade;
this.yearOfManufacture = Year;
}
carInfo(){
console.log(`Information of vehicle - ${this.model} ${this.color} ${this.yearOfManufacture}`);
}
}
let Maruti = new Vehicle("Desire", "Black", 2019)
Maruti.carInfo()
class Carr extends Vehicle {
seatCapacity : number;
constructor(Model : string, Shade : string, Year : number, SeatingCapacity : number) {
super(Model, Shade, Year);
this.seatCapacity = SeatingCapacity;
}
Driving(){
console.log(`The seating capacity for a ${this.color} ${this. model} ${this.yearOfManufacture} is ${this.seatCapacity}`)
}
}
let Renaultt = new Carr("Desire", "Black", 2019, 5);
Renaultt.Driving();