Alright so essentially I need to create a class that houses the methods and then call the methods in the form but I can't seem to find out what the right code is to call it. I think there may be an issue with the conversion from a double to a string.
This is what I have for the Class
Public Class Aircraft
Dim Names() As String = {"A-747", "A-737", "C-150", "D-240"}
Dim TakeOffVelocity() As Double = {250, 264, 270, 240}
Dim Acceleration() As Double = {33.5, 44.2, 37.1, 51.9}
Sub CalculateTakeOff1()
Dim time1 As Double = TakeOffVelocity(0)
Dim accel1 As Double = Acceleration(0)
Dim TakeOffTime1 As Double = time1 / accel1
Dim TakeOffDistance1 As Double = accel1 * time1
Dim takeOffA747 As String = ("The A-747 Aircraft has a required takeoff velocity of " + time1 +
" ft/second and an acceleration constant of " + accel1 +
". Therefore, it requires " + TakeOffTime1 +
" seconds to take off, with a distance of " + TakeOffDistance1 + " feet.")
MsgBox("The A-747 Aircraft has a required takeoff velocity of " + time1 +
" ft/second and an acceleration constant of " + accel1 +
". Therefore, it requires " + TakeOffTime1 +
" seconds to take off, with a distance of " + TakeOffDistance1 + " feet.")
End Sub
Sub CalculateTakeOff2()
Dim time2 As Double = TakeOffVelocity(1)
Dim accel2 As Double = Acceleration(1)
Dim TakeOffTime2 As Double = time2 / accel2
Dim TakeOffDistance2 As Double = accel2 * time2
Dim takeOffA737 As String = ("The A-737 Aircraft has a required takeoff velocity of " + time2 +
" ft/second and an acceleration constant of " + accel2 +
". Therefore, it requires " + TakeOffTime2 +
" seconds to take off, with a distance of " + TakeOffDistance2 + " feet.")
takeOffA737.ToString()
End Sub
Sub CalculateTakeOff3()
Dim time3 As Double = TakeOffVelocity(2)
Dim accel3 As Double = Acceleration(2)
Dim TakeOffTime3 As Double = time3 / accel3
Dim TakeOffDistance3 As Double = accel3 * time3
Dim takeOffC150 As String = ("The C-150 Aircraft has a required takeoff velocity of " + time3 +
" ft/second and an acceleration constant of " + accel3 +
". Therefore, it requires " + TakeOffTime3 +
" seconds to take off, with a distance of " + TakeOffDistance3 + " feet.")
takeOffC150.ToString()
End Sub
Sub CalculateTakeOff4()
Dim time4 As Double = TakeOffVelocity(3)
Dim accel4 As Double = Acceleration(3)
Dim TakeOffTime4 As Double = time4 / accel4
Dim TakeOffDistance4 As Double = accel4 * time4
Dim takeOffD240 As String = ("The D=240 Aircraft has a required takeoff velocity of " + time4 +
" ft/second and an acceleration constant of " + accel4 +
". Therefore, it requires " + TakeOffTime4 +
" seconds to take off, with a distance of " + TakeOffDistance4 + " feet.")
takeOffD240.ToString()
End Sub
End Class
This is the code for the form
Public Class DePlane
Private Sub txtDisplay_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtDisplay.TextChanged
End Sub
Private Sub btnGo_Click(sender As System.Object, e As System.EventArgs) Handles btnGo.Click
If cboxA747.Checked = True Then
Dim plane1 As Aircraft
plane1 = New Aircraft
plane1.CalculateTakeOff1()
ElseIf cboxA737.Checked = True Then
Dim plane2 As Aircraft
plane2 = New Aircraft
plane2.CalculateTakeOff2()
ElseIf cboxC150.Checked = True Then
Dim plane3 As Aircraft
plane3 = New Aircraft
plane3.CalculateTakeOff3()
ElseIf cboxD240.Checked = True Then
Dim plane4 As Aircraft
plane4 = New Aircraft
plane4.CalculateTakeOff4()
End If
End Sub
End Class