w11 design patterns
This commit is contained in:
11
w10-patterns/factory/index.html
Normal file
11
w10-patterns/factory/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script src="index.js"></script>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
</html>
|
||||
26
w10-patterns/factory/index.js
Normal file
26
w10-patterns/factory/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
class Computer {
|
||||
constructor(brand, os, ram, cpu, ssdSize) {
|
||||
this.brand = brand;
|
||||
this.os = os;
|
||||
this.ram = ram;
|
||||
this.cpu = cpu;
|
||||
this.ssd = ssdSize;
|
||||
}
|
||||
|
||||
showSpects() {
|
||||
console.log(
|
||||
`Brand is ${this.brand} with ${this.os} OS.
|
||||
CPU: ${this.cpu} / RAM: ${this.ram} / SSD size: ${this.ssd}
|
||||
`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Create a Builder for this
|
||||
class ComputerBuilder {}
|
||||
|
||||
// 2. Create a factory
|
||||
// 3. Change it using a singleton
|
||||
class ComputerFactory {}
|
||||
|
||||
console.log('ready');
|
||||
Reference in New Issue
Block a user