class Car {
cType: string;
constructor(ctype: string) {
this.cType = ctype;
}
run(cost:number = 0) {
console.log(this.cType + " " + cost);
}
}
class Lexus extends Car {
constructor(ctype: string) {
super(ctype);
}
run(cost = 91830) {
console.log('class Lexus extends Car')
super.run(cost);
}
}
class Ram extends Car {
constructor(ctype: string) {
super(ctype);
}
run(cost = 58645) {
console.log('class Ram extends Car')
super.run(cost);
}
}
let mObj = new Lexus("Lexus LX 2021");
let rObj = new Ram("Ram 1500 2021")
mObj.run();
rObj.run();
/*
run:
"class Lexus extends Car"
"Lexus LX 2021 91830"
"class Ram extends Car"
"Ram 1500 2021 58645"
*/