This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel { | |
val square = square { | |
lines = 8 | |
char = 'd' | |
} | |
space() | |
val triangle = triangle { | |
lines = 8 | |
char = 'd' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix fun Shape.intersection(shape: Shape): ComposedShape { | |
return ComposedShape(this, shape, ComposedShape.Operation.INTERSECTION) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix fun Shape.union(shape: Shape): ComposedShape { | |
return ComposedShape(this, shape, ComposedShape.Operation.UNION) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel { | |
val square = square { | |
lines = 8 | |
char = 'd' | |
} | |
space() | |
val triangle = triangle { | |
lines = 8 | |
char = 'd' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel { | |
val square = square { | |
lines = 8 | |
char = 'd' | |
} | |
space() | |
val triangle = triangle { | |
lines = 8 | |
char = 'd' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Panel.space() { | |
this.addShape(Space) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RhombusBuilder: ShapeBuilder() { | |
override fun build() = Rhombus(lines, char) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TriangleBuilder: ShapeBuilder() { | |
override fun build() = Triangle(lines, char) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SquareBuilder: ShapeBuilder() { | |
override fun build() = Square(lines, char) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class ShapeBuilder { | |
private companion object { | |
const val DEFAULT_CHAR = '*' | |
} | |
var char = DEFAULT_CHAR | |
var lines = 0 | |
abstract fun build(): Shape |