Sorry about the delay
namespace LinePoint {
class Program {
static void Main(string[] args) {
#region Line/ Point
Point p1 = new Point(2, 4);
Point p2 = new Point(5, 7);
p1.Draw();
p2.Draw();
Line line1 = new Line(p1, p2);
line1.Collapse();
//Point midPoint();
#endregion
}//end main
}//end class
}//end namespace
namespace LinePoint
{
class Line {
private Point _p0; //point 1
private Point _p1; //point 2
private double _slope; // research
private Point _midPoint; //point
#region Constructor
public Line(Point newP0, Point newP1) {
_p0 = newP0;
_p1 = newP1;
}// end constructor1
public Line(int x1, int y1, int x2, int y2) {
P0.X = x1;
P0.Y = y1;
P1.X = x2;
P1.Y = y2;
}//end constructor3
#endregion
#region Property
public Point P0 {
get { return _p0; }
set { _p0 = value; }
}//end property
public Point P1 {
get { return _p1; }
set { _p1 = value; }
}//end property
public double Slope { // get only
get { _slope = (P1.Y - P0.Y) / (P1.X - P0.X); return _slope; }
}//end property
public Point Midpoint { // get only
get {
_midPoint.X = (P0.X + P1.X) / 2;
_midPoint.Y = (P0.Y + P1.Y) / 2;
return _midPoint;
}
}//end property
#endregion
#region Methods
public void Draw() {
}
public void Perturb(int xmin, int xmax, int ymin, int ymax) {
Random rand = new Random();
int xEnd = rand.Next(xmin, xmax);
int yEnd = rand.Next(ymin, ymax);
if (xEnd > yEnd) {
P0.Y += xEnd;
} else {
P0.X += yEnd;
}//end if/else
}//end perturb
public void Collapse() {
int dx = P0.X - P1.X;
int dy = P0.Y - P1.Y;
int step;
int locX;
int locY;
if (Math.Abs(dx) >= Math.Abs(dy)) {
step = Math.Abs(dx);
} else {
step = Math.Abs(dy);
}//end if/
//Assign Values
dx = dx / step;
dy = dy / step;
//Assigning Locations
locX = P0.X;
locY = P0.Y;
locX = P1.X;
locY = P1.Y;
}//end draw method
#endregion
}//end class
}//end namespace
namespace LinePoint {
class Point {
//fields
private int _x = 0;
private int _y = 0;
//property
public int X {
get { return _x; }
set { _x = value; }
}//end property
public int Y {
get { return _y; }
set { _y = value; }
}//end property
//constructor
public Point(int start_x = 0, int start_y = 0) {
X = start_x;
Y = start_y;
}//end constructor
public void Draw() {
Console.SetCursorPosition(X, Y);
Console.Write("+");
}
}
}