public Line(int vertex1X, int vertex1Y, int vertex2X, int vertex2Y, string color) : base(color) { point1 = new Vertex(vertex1X, vertex1Y); point2 = new Vertex(vertex2X, vertex2Y); }
public override void Translate(Vertex toTranslate) { Center = toTranslate; }
public abstract void Translate(Vertex toTranslate);
public Circle(int centerX, int centerY, int radius, string color) : base(color) { center = new Vertex(centerX, centerY); Radius = radius; }
/* X and Y coordinate make a vertex 2 vertices make a line line is a shape */ static void Main() { Vertex v = new Vertex(1, 5); Console.WriteLine("X,Y Coordinates of first vertex: {0},{1}", v.XCoord, v.YCoord); Line l = new Line(10,2,2,4,"red"); Console.WriteLine(l.ToString()); l.Translate(v); //translate the line by the amount in vertex v //in this case, move all points by 1 x and 1 y Console.WriteLine(l.ToString()); Shape[] shapeCollection = { new Line(14, 1, -2, 1, "magenta"), new Circle(4,5, 10, "blue") }; foreach(Shape s in shapeCollection) { Console.WriteLine(s.ToString()); s.Translate(new Vertex(4, 1)); Console.WriteLine(s.ToString()); //after translate on shape } Console.ReadLine(); }
public override void Translate(Vertex toTranslate) { Point1 = toTranslate; //using property to translate point/vertex by amount Point2 = toTranslate; }