using System;
// instance_constructor.cs
class map
{
public double dx, dy;
public map() {
Console.WriteLine("No param constructor");
this.dx = 0; this.dy = 0;
Console.WriteLine(" This is a base staion alpha Location 0"); }
public map(double x, double y)
{
Console.WriteLine("constructor double param evoked");
this.dx = x;
this.dy = y;
}
public static double scale_locations()
{
Console.WriteLine("--base--");
return 1;
}
public static double scale_locations(map a, map b)
{
// method to get the input from command line
double ddx = a.dx - b.dx ;
double ddy = a.dy - b.dy ;
return Math.Sqrt(ddx * ddx + ddy * ddy);
}
public override string ToString()
{
return string.Format("({0}, {1})", dx, dy);
}
}
class test
{
static void Main()
{
Console.Write("Enter star a distance from base (p) : ");
double ds1 = double.Parse(Console.ReadLine());
Console.Write("Enter star b distance from base (b) : ");
double ds2 = double.Parse(Console.ReadLine());
map ma = new map();
map mb = new map(ds1, ds2);
double ds3 = map.scale_locations(ma, mb);
Console.WriteLine(" Locate star a & b where h = : " + ds3);
}
}
|