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
78 lines (59 loc) · 1.9 KB
/
app.js
File metadata and controls
78 lines (59 loc) · 1.9 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
// mine part one
class Person {
constructor(name, pets, residence, hobbies) {
this.name = name;
this.pets = pets;
this.residence = residence;
this.hobbies = hobbies;
}
info () {
if (this.occupation){
console.log(`My name is ${this.name} and I have ${this.pets} pets. I live in ${this.residence}, and my hobbies are ${this.hobbies}, his occupation is ${this.occupation}.`);
} else {console.log(`My name is ${this.name} and I have ${this.pets} pets. I live in ${this.residence}, and my hobbies are ${this.hobbies}.`)
}
}
greeting() {
console.log("Hello friends!");
}
}
class Coder extends Person {
constructor(name, pets, residence, hobbies, occupation) {
super(name, pets, residence, hobbies);
this.occupation = occupation;
}
greeting(){ //override the greeting
console.log("hello peeps!");
}
};
var Scott = new Person ("Scott", 0, "Burke", "3-d photography", "data-scientist")
var Logan = new Coder ("Logan", 2, "Burke", ["music ", "games"], "student")
Scott.greeting();
Scott.info();
Logan.greeting();
Logan.info();
/*
//bonus this replaces the first one
greeting(name) {
console.log(`Hello ${name}`);
}
//second ong
greeting(name) {
console.log(`${name} Back atcha`);
}
Scott.greeting(Logan.name);
Logan.greeting(Scott.name);
*/
/*
// going over excerise in class
class Person { // create a class Person with four parameters constructor has a capital letter
constructor (name, pets, residence, hobbies) { //add constructo
this.name = name;
this.pets = pets; //assisn properties
this.residence = residence;
this.hobbies = hobbies;
}
}
*/