diff --git a/Structural/Bridge/kotlin/BridgePattern.kt b/Structural/Bridge/kotlin/BridgePattern.kt new file mode 100644 index 0000000..8144392 --- /dev/null +++ b/Structural/Bridge/kotlin/BridgePattern.kt @@ -0,0 +1,45 @@ +interface Color { + fun getColor() +} + +class Yellow: Color { + override fun getColor() { + println("Yellow") + } +} + +class Red: Color { + override fun getColor() { + println("Red") + } +} + +interface House { + val color: Color + fun show() +} + +class WoodHouse(override val color: Color): House { + override fun show() { + print("The wood house color is ") + color.getColor() + } +} + +class RockHouse(override val color: Color): House { + override fun show() { + print("The rock house color is ") + color.getColor() + } +} + +fun main() { + val yellowWoodHouse = WoodHouse(color = Yellow()) + yellowWoodHouse.show() + val yellowRockHouse = RockHouse(color = Yellow()) + yellowRockHouse.show() + val redWoodHouse = WoodHouse(color = Red()) + redWoodHouse.show() + val redRockHouse = RockHouse(color = Red()) + redRockHouse.show() +} \ No newline at end of file