-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoop2.js
33 lines (27 loc) · 855 Bytes
/
oop2.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
import { BaseLogger, EmailLogger, FileLogger, SmsLogger } from "./oop3.js";
import House from "./oop.js";
console.log("------------------");
class HouseService {
constructor(logger) {
//x loggerType
this.houses = [];
this.logger = logger;
// this.loggerType = loggerType;
}
list(filterCb) {
// callback
console.log(filterCb !== undefined ? this.houses.filter(filterCb) : this.houses); // ternary operator
// false, 0, null, undefined, NaN, ""
// Boolean()
}
add(house) {
this.houses.push(house);
this.logger.log("Yeni bir ev eklendi.", house); //x , this.loggerType
}
}
// konfigürasyon
const logger = new SmsLogger(); // PnP, plug and play mimarisi
//
const houseService = new HouseService(logger); //x , "email"
const newHouse = new House(3, 2, "Kuzey", 100, 5000);
houseService.add(newHouse);