-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_ClassAssignA.js
67 lines (53 loc) · 1.73 KB
/
09_ClassAssignA.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Vehicle class
class Vehicle {
constructor(brand, type, model, engineType) {
this.brand = brand;
this.type = type;
this.model = model;
this.engineType = engineType;
}
display() {
console.log();
console.log(`Brand : ${this.brand}`);
console.log(`Model : ${this.model}`);
console.log(`Vehicle type : ${this.type} car`);
console.log(`Engine type : ${this.engineType} engine.`);
console.log();
console.log('--------------------------');
}
}
const BMW1 = new Vehicle("BMW", "Sports", "M5 Comptition", "V8");
const Audi = new Vehicle("Audi", "Sports", "A8", "V6");
const Mercedes = new Vehicle("Mercedes", "Sports", "AMG GT63", "V8");
const Lamborghini = new Vehicle("Lamborghini", "Sports", "Urus", "V8");
const BMW2 = new Vehicle("BMW", "Sports", "M4", "V8");
const arrayOfObjects = [BMW1, Audi, Mercedes, Lamborghini, BMW2];
console.log();
console.log('Vehicle details ->');
for (const Car of arrayOfObjects) {
Car.display();
}
// College class
class College {
constructor(name, city, grade, type) {
this.name = name;
this.city = city;
this.grade = grade;
this.type = type;
}
display() {
console.log(`Name : ${this.name}, City - ${this.city}, College Type - ${this.type}`);
}
}
console.log();
console.log('College details ->');
console.log();
const COEP = new College("COEP", "Pune", "A+", "Autonomous");
COEP.display();
const Sinhgad = new College("Sinhgad", "Pune", "A+", "Private");
Sinhgad.display();
const MIT = new College("MIT", "Pune", "A+", "Autonomous");
MIT.display();
const Walchand = new College("Walchand", "Sangli", "A+", "Autonomous");
Walchand.display();
console.log();