forked from truecodersio/JavaScript_OOP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (42 loc) · 1 KB
/
app.js
File metadata and controls
47 lines (42 loc) · 1 KB
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
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
class Person {
constructor(name, pets, residence, hobbies) {
this.name = name;
this.pets = pets;
this.residence = residence;
this.hobbies = hobbies;
}
info() {
console.log(
`The Person is ${this.name}, with ${this.pets}, from ${
this.residence
}, who enjoys ${this.hobbies.join(" and ")}.`
);
}
greeting(name) {
console.log(`Hello ${name}!`);
}
}
class Coder extends Person {
constructor(name, pets, residence, hobbies) {
super(name, pets, residence, hobbies);
this.occupation = "Full Stack Web Developer";
}
greeting(name) {
console.log(`Hello ${name}! I'm a ${this.occupation}`);
}
}
let person = new Person("Wilem", 2, "Ceald", [
"playing corners",
"reading",
"listening to music",
]);
person.info();
let coder = new Coder("Ben", 0, "Birmingham", [
"running",
"reading",
"scenic driving",
]);
coder.greeting(person.name);