Exemplo n.º 1
0
 void Calculate(object sender, EventArgs e)
 {
     try
     {
         if (calculateTo.SelectedIndex == -1)
         {
             Alerts.InvalidInput(messageToUser: AppResources.emtpyEquationPickerCalculate);
         }
         else
         {
             if (calculateTo.SelectedIndex == 0)
             {
                 Result.Text = Velocity_VUAT.getFinalVelocity(initialVelocityEntry.Text, accelerationEntry.Text, timeEntry.Text).ToString();
                 //showHow.Text = $"The distance travelled of and object is equal to the velocity of the object times the time it takes. \r\n {Result.Text} = {velocityEntry.Text} * {timeEntry.Text}";
             }
             else if (calculateTo.SelectedIndex == 1)
             {
                 Result.Text = Velocity_VUAT.getInitialVelocity(finalVelocityEntry.Text, accelerationEntry.Text, timeEntry.Text).ToString();
                 //showHow.Text = $"The distance travelled of and object is equal to the velocity of the object times the time it takes. \r\n {Result.Text} = {velocityEntry.Text} * {timeEntry.Text}";      }
             }
             else if (calculateTo.SelectedIndex == 2)
             {
                 Result.Text = Velocity_VUAT.getAcceleration(finalVelocityEntry.Text, initialVelocityEntry.Text, timeEntry.Text).ToString();
                 //showHow.Text = $"The distance travelled of and object is equal to the velocity of the object times the time it takes. \r\n {Result.Text} = {velocityEntry.Text} * {timeEntry.Text}";  }
             }
             else
             {
                 Result.Text = Velocity_VUAT.getTime(finalVelocityEntry.Text, initialVelocityEntry.Text, accelerationEntry.Text).ToString();
             }
         }
     }
     catch (FormatException j)
     {
         Alerts.InvalidInput(messageToUser: AppResources.errorFormatMessage);
     }
     catch (DivideByZeroException j)
     {
         Alerts.InvalidInput(messageToUser: AppResources.errorDivideByZeroMessage);
     }
     catch (Exception j)
     {
         Alerts.InvalidInput(messageToUser: j.Message);
     }
 }
Exemplo n.º 2
0
        public void VUAT_Can_Calculate_FinalVelocity()
        {
            var finalVelocity = Velocity_VUAT.getFinalVelocity("100", "10", "10");

            Assert.IsTrue(finalVelocity == (decimal)200);
        }