-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathFacade.kt
37 lines (32 loc) · 850 Bytes
/
Facade.kt
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
package org.vld.sdp.structural
/**
* CPU subsystem/dependency of a larger [Computer] system
*/
class Cpu {
fun start(): String = "CPU started"
}
/**
* RAM subsystem/dependency of a larger [Computer] system
*/
class Ram {
fun load(): String = "RAM loaded"
}
/**
* SSD subsystem/dependency of a larger [Computer] system
*/
class Ssd {
fun read(): String = "SSD read"
}
/**
* Computer Facade higher-level, simplified interface to a larger [Computer] system
*/
interface Computer {
fun switchOn(): String
}
/**
* Computer Facade higher-level, simplified interface implementation
*/
class Desktop(private val cpu: Cpu, private val ram: Ram, private val ssd: Ssd) : Computer {
// hide complexities and dependencies of a larger system
override fun switchOn(): String = "${cpu.start()}, ${ram.load()}, ${ssd.read()}"
}