Did a lot of work just unit testing left

This commit is contained in:
2019-10-25 02:30:49 -06:00
parent 8d6ba5df72
commit 6901925c69
15 changed files with 508 additions and 74 deletions

View File

@@ -1,46 +1,38 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
namespace Shapes
{
[DataContract]
[KnownType(typeof(CompositeShape))]
public abstract class Shape
{
public abstract double Width { get; }
public abstract double Height { get; }
[DataMember]
public virtual List<Point> Points { get; internal set; }
[DataMember]
public abstract Color Fill { get; set; }
[DataMember]
public abstract Color Stroke { get; set; }
[DataMember]
protected internal bool CompositeShape { get; set; }
public Shape()
{
CompositeShape = false;
}
public abstract double ComputeArea();
public abstract Point CenterPoint { get; }
public virtual List<Point> Points { get; }
public abstract void Scale(double scaleFactor);
public void Rotate(double degrees)
{
double radians = degrees * (Math.PI / 180);
double cosTheta = Math.Cos(radians);
double sinTheta = Math.Sin(radians);
foreach (var point in Points)
{
var oldPoint = point;
var tempX = oldPoint.X - CenterPoint.X;
var tempY = oldPoint.Y - CenterPoint.X;
var rotatedX = tempX*cosTheta - tempY*sinTheta;
var rotatedY = tempX*sinTheta + tempY*cosTheta;
point.X = rotatedX + CenterPoint.X;
point.Y = rotatedY + CenterPoint.Y;
}
}
public abstract void Save(Stream stream);
public abstract void Draw(Stream stream);
}
}