示例#1
0
 public static Distance operator /(Distance s, int x)
 {
     Distance newS = new Distance(0);
     newS.distanceType = s.distanceType;
     newS.value = s.value / x;
     return newS;
 }
示例#2
0
 public static Distance operator *(SquireTime tt, Acceleration a)
 {
     Distance s = new Distance(0);
     s.distanceType = a.distanceType;
     s.value =  tt.value * a.value;
     return s;
 }
示例#3
0
 public Distance ConvertFromSI(Distance x)
 {
     Distance newValue = new Distance(1);
     newValue.distanceType = x.distanceType;
     newValue.value = x.value / ConvertDistanceToSI(newValue);
     return newValue;
 }
示例#4
0
 public static Distance operator +(int x, Distance s)
 {
     Distance newS = new Distance(0);
     newS.distanceType = s.distanceType;
     newS.value = s.value + x;
     return newS;
 }
示例#5
0
 public static Distance operator *(Time t, Speed v)
 {
     Distance s = new Distance(0);
     s.distanceType = v.distanceType;
     Converter converter = new Converter();
     s.value = converter.ConvertToSI(v).value * converter.ConvertToSI(t).value;
     return converter.ConvertFromSI(s);
 }
示例#6
0
 public new string GiveValueInSI()
 {
     Distance x = new Distance(value);
     x.distanceType = distanceType;
     Converter conv = new Converter();
     string message = conv.ConvertToSI(x).value + " m";
     return message;
 }
示例#7
0
 static void Main(string[] args)
 {
     Time t = new Time(5);
     Speed v = new Speed(10);
     Distance s = new Distance(10);
     Acceleration a = new Acceleration(3);
     s = 2 + (a * (t^2)) / 2;
     Converter conv = new Converter();
     Console.WriteLine(a.GiveValueInSI());
     Console.ReadLine();
 }
示例#8
0
 public double ConvertDistanceToSI(Distance x)
 {
     double value = x.value;
     switch (x.distanceType)
     {
         case ("mile"): value = x.value * 1609.27; break;
         case ("km"): value = x.value * 1000; break;
         case ("sm"): value = x.value / 100; break;
         case ("mm"): value = x.value / 1000; break;
     }
     return value;
 }
示例#9
0
        public Speed ConvertFromSI(Speed x)
        {
            Speed newValue = new Speed(0);
            newValue.distanceType = x.distanceType;
            newValue.timeType = x.timeType;

            Distance s = new Distance(x.value);
            s.distanceType = x.distanceType;
            s = ConvertFromSI(s);

            Time t = new Time(1);
            t.timeType = x.timeType;
            t = ConvertFromSI(t);

            newValue.value = s.value / t.value;
            return newValue;
        }
示例#10
0
 public Distance ConvertToSI(Distance x)
 {
     Distance newValue = new Distance(0);
     newValue.distanceType = "m";
     newValue.value = ConvertDistanceToSI(x);
     return newValue;
 }
示例#11
0
        public Speed ConvertToSI(Speed x)
        {
            Speed newValue = new Speed(0);
            newValue.distanceType = "m";
            newValue.timeType = "s";

            Distance s = new Distance(x.value);
            newValue.value = ConvertDistanceToSI(s);

            Time t = new Time(1);
            t.timeType = x.timeType;

            newValue.value = newValue.value / ConvertTimeToSI(t);
            return newValue;
        }
示例#12
0
 public static Distance operator -(Distance s1, Distance s2)
 {
     Distance s3 = new Distance(0);
     s3.value = s1.value - s2.value;
     return s3;
 }