diff --git a/Advanced Software Engineering/Advanced Software Engineering/Command.cs b/Advanced Software Engineering/Advanced Software Engineering/Command.cs index 7bb32ad..7ddfff9 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Command.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Command.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Advanced_Software_Engineering { @@ -29,7 +31,7 @@ namespace Advanced_Software_Engineering public void ExecuteCommand() { - + verb.ExecuteVerb(); } public Type getType() @@ -43,16 +45,72 @@ namespace Advanced_Software_Engineering { public static Dictionary verbTypes = new Dictionary() { - { "moveto", typeof(MoveTo) } + { "moveto", typeof(MoveTo) }, + { "drawto", typeof(DrawTo) }, + { "clear", null}, + { "rectangle", null }, + { "circle", null }, + { "triangle", null }, + { "pen", null}, + { "fill", null } }; + public abstract List> acceptedTypes { + get; + } + public abstract void ExecuteVerb(); } class MoveTo : Verb { + public override List> acceptedTypes + { + get + { + return new List> { + new List { typeof(Drawer), typeof(int), typeof(int) }, + new List { typeof(Drawer), typeof(Point) } + }; + } + } + protected Drawer drawer; + protected Point moveToPoint; + + public MoveTo(Drawer drawer, int x, int y) + { + this.drawer = drawer; + this.moveToPoint = new Point(x, y); + } + + public MoveTo(Drawer drawer, Point point) + { + this.drawer = drawer; + this.moveToPoint = point; + } + + public override void ExecuteVerb() + { + this.drawer.MovePen(moveToPoint); + } + + } + + class DrawTo : MoveTo + { + public DrawTo(Drawer drawer, int x, int y) : base(drawer, x, y) { } + + public DrawTo(Drawer drawer, Point point) : base(drawer, point) { } + + public override void ExecuteVerb() + { + bool penStatus = drawer.isPenDown(); + if(!penStatus) drawer.PenDown(); + base.ExecuteVerb(); + if (!penStatus) drawer.PenUp(); + } } abstract class Value @@ -60,7 +118,7 @@ namespace Advanced_Software_Engineering } - class FlowControl : Verb //This one will help us in part 2 + class FlowControl //: Verb //This one will help us in part 2 { }