Вы находитесь на странице: 1из 3

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
string point1,point2,point3;
int[] num;
num = new int[6];
Console.Write("********~~~~ WELCOME TO 2D AND 3D POINT CALCULATOR :~
~~~~********* ");
Console.Write("\n***************************************************
********");
Console.Write("\nEnter value of X for 1st 2D Constructor : ");
point1 = Console.ReadLine();

num[0] = int.Parse(point1);
Console.Write("Enter value of Y for 1st 2D Constructor : ");
point2 = Console.ReadLine();
num[1] = int.Parse(point2);
Console.Write("Enter value of Z for 1st 3D Constructor : ");
point3 = Console.ReadLine();
num[2] = int.Parse(point3);
Console.Write("Enter value of X for 2nd 2D Constructor : ");
point1 = Console.ReadLine();
num[3] = int.Parse(point1);
Console.Write("Enter value of Y for 2nd 2D Constructor : ");
point2 = Console.ReadLine();
num[4] = int.Parse(point2);
Console.Write("Enter value of Z for 2nd 3D Constructor : ");
point3 = Console.ReadLine();
num[5] = int.Parse(point3);
TwoDPoint object1 = new TwoDPoint(num[0], num[1]);
ThreeDPoint object2 = new ThreeDPoint();
ThreeDPoint object3 = new ThreeDPoint(num[0], num[1], num[2]);
ThreeDPoint object4 = new ThreeDPoint(num[3],num[4],num[5]);
Console.WriteLine("The Graphical representation of point in graph");
object2.drawGraph(object3, object4);
object1 = object1 - object4;
Console.Write("2DPoints, Distance between A and B is: ");
object1.ShowDistance();
object2 = object3 * object4;
Console.Write("3DPoints, Distance between A and B is: ");
object2.ShowDistance();
}
}
class TwoDPoint
{
protected int x;
protected int y;
public TwoDPoint()
{
x = 0;
y = 0;
}
public TwoDPoint(int a, int b)
{
x = a;
y = b;
}
public virtual void ShowDistance()
{
double ans = System.Math.Sqrt(x + y);
Console.WriteLine(String.Format("{0:0.00}", ans));
}
public static TwoDPoint operator -(TwoDPoint object1, TwoDPoint object2)
{
TwoDPoint OO = new TwoDPoint();
OO.x=(object1.x - object2.x) * 2;
OO.y=(object1.y - object2.y) * 2;
return OO;
}
}
class ThreeDPoint : TwoDPoint
{
private int z;
public ThreeDPoint() : base()
{
z = 0;
}
public ThreeDPoint(int a, int b, int c)
: base(a, b)
{
z = c;//IU
}
public static ThreeDPoint operator *(ThreeDPoint object1, ThreeDPoint ob
ject2)
{
ThreeDPoint TT= new ThreeDPoint();
TT.x=(object1.x - object2.x) * 2;
TT.y=(object1.y - object2.y) * 2;
TT.z=(object1.z - object2.z) * 2;
return TT;
}
public void drawGraph(ThreeDPoint obj, ThreeDPoint obj1)
{
char[,] Emma;
Emma = new char[10, 10];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
Emma[i, j] = '.';
}
}
Emma[obj.x, obj.y] = 'A';
Emma[obj1.x, obj1.y] = 'B';
for (int k = 9; k >= 0; k--)
{
Console.Write(k + 1);
Console.Write("\t");
for (int l = 0; l < 10; l++)
{
Console.Write(Emma[k, l]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.Write("\t");
for (int k = 0; k < 10; k++)
{
Console.Write(k + 1);
Console.Write(" ");
}
Console.WriteLine();
}
public override void ShowDistance()
{
Console.WriteLine(String.Format("{0:0.00}", System.Math.Sqrt(x + y +
z)));
}
}
}

Вам также может понравиться