Exemplo n.º 1
0
        public void Operators()
        {
            Assert.AreEqual(2 * Length.Metre, Length.Metre + Length.Metre);
            Assert.AreEqual(1 * Length.Metre, (2 * Length.Metre) - Length.Metre);
            Assert.AreEqual(1 * Length.Metre, (2 * Length.Metre) / 2);
            Assert.AreEqual(100 * Area.SquareMetre, (10 * Length.Metre) * (10 * Length.Metre));
            Assert.AreEqual(960, (10 * Length.Inch) * (96 * TypographicResolution.DotsPerInch));

            Length   s = 100 * Length.Metre;
            Time     t = 9.58 * Time.Second;
            Velocity v = s / t;

            Assert.AreEqual(10.44, v.ConvertTo(Velocity.MetrePerSecond), 0.01);
            Assert.AreEqual(37.58, v.ConvertTo(Velocity.KilometrePerHour), 0.01);
        }
Exemplo n.º 2
0
        public void Operators()
        {
            Assert.AreEqual(2 * Length.Metre, Length.Metre + Length.Metre);
            Assert.AreEqual(1 * Length.Metre, (2 * Length.Metre) - Length.Metre);
            Assert.AreEqual(1 * Length.Metre, (2 * Length.Metre) / 2);
            Assert.AreEqual(100 * Area.SquareMetre, (10 * Length.Metre) * (10 * Length.Metre));

            Length   s = 100 * Length.Metre;
            Time     t = 9.58 * Time.Second;
            Velocity v = s / t;

            Console.WriteLine(v.ToString("0.00"));
            Console.WriteLine(v.ToString("0.00 km/h"));

            Assert.AreEqual(10.44, v.ConvertTo(Velocity.MetrePerSecond), 0.01);
            Assert.AreEqual(37.58, v.ConvertTo(Velocity.KilometrePerHour), 0.01);
        }
Exemplo n.º 3
0
        public static Velocity Accelerate(Meter metersPerSecondSquared, Second durationOfAccelerationInSeconds, Velocity initialVelocity)
        {
            var velocityInMs = initialVelocity.ConvertTo(Velocity.Ms);

            var newVelocityInMs = velocityInMs.Value + (metersPerSecondSquared.Value * durationOfAccelerationInSeconds.Value);

            return(Velocity.Create(newVelocityInMs, Velocity.Ms).ConvertTo(initialVelocity.Unit));
        }