Upload files to "/"
This commit is contained in:
61
mewhenimbored.ts
Normal file
61
mewhenimbored.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
enum CarType {
|
||||
Sedan = 'Sedan',
|
||||
SUV = 'SUV',
|
||||
Hatchback = 'Hatchback',
|
||||
Truck = 'Truck',
|
||||
Coupe = 'Coupe',
|
||||
}
|
||||
|
||||
enum RunsOn {
|
||||
Gasoline = 'Gasoline',
|
||||
Diesel = 'Diesel',
|
||||
Hybrid = 'Hybrid',
|
||||
Electric = 'Electric',
|
||||
}
|
||||
|
||||
// interface ICar {
|
||||
// make: string;
|
||||
// model: string;
|
||||
// year: number;
|
||||
// body: CarType;
|
||||
// powertrain: RunsOn;
|
||||
// engine: string;
|
||||
// mpg: number;
|
||||
// link?: string;
|
||||
// }
|
||||
|
||||
class Car {
|
||||
constructor(
|
||||
public make: string,
|
||||
public model: string,
|
||||
public year: number,
|
||||
public body: CarType,
|
||||
public powertrain: RunsOn,
|
||||
public engine: string,
|
||||
public mpg: number,
|
||||
public link?: string
|
||||
) {}
|
||||
|
||||
public info(): string {
|
||||
// return `${this.year} ${this.make} ${this.model} (${this.body}) - Engine: ${this.engine}, Powertrain: ${this.powertrain}, MPG: ${this.mpg} \nAnd Visit ${this.link} for more infomation`;
|
||||
let result = `${this.year} ${this.make} ${this.model} (${this.body}) - Engine: ${this.engine}, Powertrain: ${this.powertrain}, MPG: ${this.mpg}`;
|
||||
if (this.link) {
|
||||
result += `\nAnd Visit ${this.link} for more information`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const myCar = new Car(
|
||||
'Honda', // Make
|
||||
'Civic', // Model
|
||||
2025, // Year
|
||||
CarType.Hatchback, // Body
|
||||
RunsOn.Gasoline, // PowerTrain
|
||||
'2L 4-Cylinder', // Engine
|
||||
49,
|
||||
"https://automobiles.honda.com/2024/civic-sedan/specs-features-trim-comparison"
|
||||
);
|
||||
|
||||
console.log(myCar.info());
|
||||
Reference in New Issue
Block a user