Private
Public Access
Better Exceptions
This commit is contained in:
1 parent
6f961f908b
commit
443c6a9208
2 files changed
+14
-16
No files matched your search
-2
@@ -14,8 +14,6 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
/// Correct
|
/// Correct
|
||||||
/// </todo>
|
/// </todo>
|
||||||
public class Rectangle : Verb {
|
public class Rectangle : Verb {
|
||||||
Verb verb;
|
|
||||||
|
|
||||||
Drawer drawer;
|
Drawer drawer;
|
||||||
PointF[] points;
|
PointF[] points;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
DrawTo(drawer,
|
DrawTo(drawer,
|
||||||
Value.ConvertToInt(parameters[0]),
|
Value.ConvertToInt(parameters[0]),
|
||||||
Value.ConvertToInt(parameters[1]));
|
Value.ConvertToInt(parameters[1]));
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "regularpolygon":
|
case "regularpolygon":
|
||||||
case "rp":
|
case "rp":
|
||||||
//Check parameters
|
//Check parameters
|
||||||
@@ -67,7 +67,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToDouble(parameters[1]),
|
Value.ConvertToDouble(parameters[1]),
|
||||||
Value.ConvertToDouble(parameters[2])
|
Value.ConvertToDouble(parameters[2])
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "square":
|
case "square":
|
||||||
//Check parameters
|
//Check parameters
|
||||||
if (parameters.Length == 1) {
|
if (parameters.Length == 1) {
|
||||||
@@ -80,7 +80,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToDouble(parameters[0]),
|
Value.ConvertToDouble(parameters[0]),
|
||||||
Value.ConvertToDouble(parameters[1])
|
Value.ConvertToDouble(parameters[1])
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "quadrilateral":
|
case "quadrilateral":
|
||||||
//Check parameters
|
//Check parameters
|
||||||
if (parameters.Length == 8) {
|
if (parameters.Length == 8) {
|
||||||
@@ -90,7 +90,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToPoint(parameters[4], parameters[5]),
|
Value.ConvertToPoint(parameters[4], parameters[5]),
|
||||||
Value.ConvertToPoint(parameters[6], parameters[7])
|
Value.ConvertToPoint(parameters[6], parameters[7])
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "rectangle":
|
case "rectangle":
|
||||||
//Check parameters
|
//Check parameters
|
||||||
if (parameters.Length == 2) {
|
if (parameters.Length == 2) {
|
||||||
@@ -105,7 +105,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToPoint(parameters[4], parameters[5]),
|
Value.ConvertToPoint(parameters[4], parameters[5]),
|
||||||
Value.ConvertToPoint(parameters[6], parameters[7])
|
Value.ConvertToPoint(parameters[6], parameters[7])
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "circle":
|
case "circle":
|
||||||
//Check parameters
|
//Check parameters
|
||||||
if (parameters.Length == 1) {
|
if (parameters.Length == 1) {
|
||||||
@@ -113,7 +113,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Circle(drawer,
|
Circle(drawer,
|
||||||
Value.ConvertToDouble(parameters[0])
|
Value.ConvertToDouble(parameters[0])
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "triangle":
|
case "triangle":
|
||||||
//Check parameters
|
//Check parameters
|
||||||
if (parameters.Length == 1) {
|
if (parameters.Length == 1) {
|
||||||
@@ -133,34 +133,34 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToPoint(parameters[2], parameters[3]),
|
Value.ConvertToPoint(parameters[2], parameters[3]),
|
||||||
Value.ConvertToPoint(parameters[4], parameters[5])
|
Value.ConvertToPoint(parameters[4], parameters[5])
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
|
|
||||||
case "dot":
|
case "dot":
|
||||||
if (parameters.Length == 0) {
|
if (parameters.Length == 0) {
|
||||||
return new Dot(drawer);
|
return new Dot(drawer);
|
||||||
} else throw new Exception("Command doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
|
|
||||||
|
|
||||||
case "clear":
|
case "clear":
|
||||||
if (parameters.Length == 0) {
|
if (parameters.Length == 0) {
|
||||||
return new Clear(drawer);
|
return new Clear(drawer);
|
||||||
} else throw new Exception("Command doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
|
|
||||||
case "reset":
|
case "reset":
|
||||||
case "resetpen":
|
case "resetpen":
|
||||||
if (parameters.Length == 0) {
|
if (parameters.Length == 0) {
|
||||||
return new ResetPen(drawer);
|
return new ResetPen(drawer);
|
||||||
} else throw new Exception("Command doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
|
|
||||||
case "fillon":
|
case "fillon":
|
||||||
if (parameters.Length == 0) {
|
if (parameters.Length == 0) {
|
||||||
return new Fill(drawer, true);
|
return new Fill(drawer, true);
|
||||||
} else throw new Exception("Command doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
|
|
||||||
case "filloff":
|
case "filloff":
|
||||||
if (parameters.Length == 0) {
|
if (parameters.Length == 0) {
|
||||||
return new Fill(drawer, false);
|
return new Fill(drawer, false);
|
||||||
} else throw new Exception("Command doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
|
|
||||||
case "pen":
|
case "pen":
|
||||||
if (parameters.Length == 1) {
|
if (parameters.Length == 1) {
|
||||||
@@ -182,7 +182,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToInt(parameters[3])
|
Value.ConvertToInt(parameters[3])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
case "fill":
|
case "fill":
|
||||||
if (parameters.Length == 1) {
|
if (parameters.Length == 1) {
|
||||||
return new FillColor(drawer, Value.TextToColor(parameters[0]));
|
return new FillColor(drawer, Value.TextToColor(parameters[0]));
|
||||||
@@ -203,7 +203,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Value.ConvertToInt(parameters[3])
|
Value.ConvertToInt(parameters[3])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else throw new Exception("Command has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown command");
|
throw new Exception("Unknown command");
|
||||||
|
|||||||
Reference in new issue
Block a user