first unit test
This commit is contained in:
@@ -6,29 +6,29 @@ namespace Shapes
|
||||
[DataContract(Name = "Points", Namespace = "Shapes")]
|
||||
public class Point
|
||||
{
|
||||
[DataMember]
|
||||
public double X { get; internal set; }
|
||||
[DataMember]
|
||||
public double Y { get; internal set; }
|
||||
[DataMember]
|
||||
public Color Color { get; set; }
|
||||
|
||||
public Point(double x, double y)
|
||||
{
|
||||
Validator.ValidateDouble(x, "Invalid x-location point");
|
||||
Validator.ValidateDouble(y, "Invalid y-location point");
|
||||
X = x;
|
||||
Y = y;
|
||||
Y = y;
|
||||
Color = Color.Black;
|
||||
}
|
||||
|
||||
[DataMember] public double X { get; internal set; }
|
||||
|
||||
[DataMember] public double Y { get; internal set; }
|
||||
|
||||
[DataMember] public Color Color { get; set; }
|
||||
|
||||
/**
|
||||
* Move the point in the x direction
|
||||
*
|
||||
* @param deltaX The delta amount to move the point -- must be a valid double
|
||||
* @throws ShapeException Exception thrown if the parameter is invalid
|
||||
*/
|
||||
public void MoveX(double deltaX) {
|
||||
public void MoveX(double deltaX)
|
||||
{
|
||||
Validator.ValidateDouble(deltaX, "Invalid delta-x value");
|
||||
X += deltaX;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace Shapes
|
||||
* @param deltaX The delta amount to move the point in the x direction -- must be a valid double
|
||||
* @param deltaY The delta amount to move the point in the y direction -- must be a valid double
|
||||
* @throws ShapeException Exception throw if any parameter is invalid
|
||||
*/
|
||||
*/
|
||||
public void Move(double deltaX, double deltaY)
|
||||
{
|
||||
MoveX(deltaX);
|
||||
@@ -74,20 +74,19 @@ namespace Shapes
|
||||
var y = point1.Y - point2.Y;
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
|
||||
public static Point operator +(Point point1, Point point2)
|
||||
{
|
||||
var x = point1.X + point2.X;
|
||||
var y = point1.Y + point2.Y;
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
|
||||
public static Point operator /(Point point1, double divisor)
|
||||
{
|
||||
var x = point1.X / divisor;
|
||||
var y = point1.Y / divisor;
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user