Documented RegularPolygon

This commit is contained in:
Lukasz Baldyga committed 2020-11-03 12:57:39 +00:00
1 parent 8a73c1cd48
commit ff8bda2f66
1 file changed
+21 -5
@@ -10,13 +10,22 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
/// A class that generates a RegularPolygon verb. /// A class that generates a RegularPolygon verb.
/// </summary> /// </summary>
public class RegularPolygon : Verb { public class RegularPolygon : Verb {
protected Drawer drawer; Drawer drawer;
protected int sides; int sides;
protected double scale; double scale;
protected double offset; double offset;
List<Point> points; List<Point> points;
/// <summary>
/// Draws a regular polygon.
/// See <see href="https://en.wikipedia.org/wiki/Regular_polygon"/>.
/// See also <seealso href="https://www.mathsisfun.com/geometry/regular-polygons.html"/>.
/// </summary>
/// <param name="drawer">drawer</param>
/// <param name="sides">Number of sides in the regular polygon</param>
/// <param name="scale">The scale of the regular polygon</param>
/// <param name="offset">Rotation offset of the regular polygon</param>
/// <param name="degMode">Default is true. If true, offset is in degrees. If false, offset is in gradians.</param>
public RegularPolygon(Drawer drawer, int sides, double scale, double offset = 0, bool degMode = true) { public RegularPolygon(Drawer drawer, int sides, double scale, double offset = 0, bool degMode = true) {
points = new List<Point>(); points = new List<Point>();
@@ -39,6 +48,9 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
this.offset = offset; this.offset = offset;
} }
/// <summary>
/// Draws the regular polygons
/// </summary>
public void ExecuteVerb() { public void ExecuteVerb() {
Point currentOrigin = drawer.GetPenPosition(); Point currentOrigin = drawer.GetPenPosition();
List<Point> originShiftedPoints = new List<Point>(); List<Point> originShiftedPoints = new List<Point>();
@@ -46,6 +58,10 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
drawer.DrawLines(originShiftedPoints.ToArray()); drawer.DrawLines(originShiftedPoints.ToArray());
} }
/// <summary>
/// Describes how the regular polygon will be drawn
/// </summary>
/// <returns>A description of how the polygon will be drawn</returns>
public string GetDescription() { public string GetDescription() {
return "Draws a " + sides + " sided regular polygon, with rotation of " + offset + " radians, with inner radius of " + scale; return "Draws a " + sides + " sided regular polygon, with rotation of " + offset + " radians, with inner radius of " + scale;
} }