90 lines
No EOL
2.3 KiB
Text
90 lines
No EOL
2.3 KiB
Text
= Things about the completed assignment:
|
|
|
|
== Class Diagram:
|
|
[plantuml]
|
|
----
|
|
@startuml
|
|
|
|
abstract class Shape {
|
|
# static int _nextId
|
|
# const double DefaultLineThickness
|
|
+ int Id { get }
|
|
# Point Position
|
|
# Point Scale
|
|
# double? LineThickness
|
|
# IBrush? LineColor
|
|
# IBrush? FillColor
|
|
# Shape(Point, Point, double?, IBrush?, IBrush?)
|
|
+ {abstract} bool DrawSelf(Point, Point, double?, IBrush?, IBrush? )
|
|
+ {abstract} bool PointInShape(Point mousePoint)
|
|
}
|
|
|
|
class Square {
|
|
- const int SideLengthMin
|
|
- const int SideLengthMax
|
|
+ Square(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool DrawSelf(Point, Point scale, double?, IBrush?, IBrush?)
|
|
+ override bool PointInShape(Point)
|
|
}
|
|
|
|
class Rectangle {
|
|
- const int SideLengthMin
|
|
- const int SideLengthMax
|
|
+ Rectangle(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool DrawSelf(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool PointInShape(Point)
|
|
}
|
|
|
|
class Circle {
|
|
- const int RadiusMin
|
|
- const int RadiusMax
|
|
+ Circle(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool DrawSelf(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool PointInShape(Point)
|
|
}
|
|
|
|
class Triangle {
|
|
- const int SideLengthMin
|
|
- const int SideLengthMax
|
|
+ Triangle(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool DrawSelf(Point, Point, double?, IBrush?, IBrush?)
|
|
+ override bool PointInShape(Point)
|
|
- static Point[] CalculateTriangleVertices(Point, double)
|
|
- static bool IsPointInTriangle(Point, Point, Point, Point)
|
|
}
|
|
|
|
class ShapeGenerator {
|
|
- double _maxX
|
|
- double _maxY
|
|
- int _nextShape
|
|
- Random _random
|
|
- const int MinShapeIdx
|
|
- const int MaxShapeIdx
|
|
- static readonly IBrush[] colors
|
|
+ ShapeGenerator(double, double)
|
|
+ Shape CreateNewShape(Point)
|
|
}
|
|
|
|
class Program {
|
|
- List<Shape> shapes
|
|
- ShapeGenerator generator
|
|
+ void Run()
|
|
+ void HandleClick(ClickEvent)
|
|
+ void Redraw()
|
|
}
|
|
|
|
Shape <|-- Square
|
|
Shape <|-- Rectangle
|
|
Shape <|-- Circle
|
|
Shape <|-- Triangle
|
|
ShapeGenerator ..> Shape : creates >
|
|
Program o-- ShapeGenerator
|
|
Program o-- "*" Shape : contains >
|
|
|
|
@enduml
|
|
----
|
|
|
|
== Side notes:
|
|
|
|
- Feature: When it attempts to create a new shape out of the bounds of the canvas, it fails and notifies the user
|
|
- No unit tests, because writing testcases is doubting your coding abilities. It's a sign of weakness. (and checking shapes on canvas could prove to be difficult) |