I have a program that takes user input from a textbox. Based on those 3 numbers it will tell them whether it is a right triangle, equilateral triangle or not a triangle. I've written 3 constructors (get/set) to take the lengths. Now I need two readonly (get only) constructors to determine whether something is right or equilateral. I'm really not sure how I would write the formula in vb. I understand a right triangle is a2 + b2 = c2 but i'm not sure how I could process a math formula inside a constructor. I guess I am also trying to learn how these two new constructors would interact with the 3 already written?
Code:
Public Class Triangle 'declare integers for 3 triangle sides Dim m_intSide1 As Integer Dim m_intSide2 As Integer Dim m_intSide3 As Integer 'Triangle constructor, sides supplied Public Sub New(ByVal side1Value As Integer, ByVal side2Value As Integer, _ ByVal side3Value As Integer) m_intSide1 = side1Value m_intSide2 = side2Value m_intSide3 = side3Value End Sub 'New 'property side1 Public Property Side1() As Integer 'return m_intSide1 value Get Return m_intSide1 End Get 'end of Get accessor 'set m_intside1 value Set(ByVal Value As Integer) 'if side 1 value entered is valid If (Value > 0) Then m_intSide1 = Value Else m_intSide1 = 0 'set invalid input to 0 End If End Set 'end of set accessor End Property 'property side2 Public Property Side2() As Integer 'return m_intSide2 value Get Return m_intSide2 End Get 'end of Get accessor 'set m_intside2 value Set(ByVal Value As Integer) 'if side 2 value entered is valid If (Value > 0) Then m_intSide2 = Value Else m_intSide2 = 0 'set invalid input to 0 End If End Set 'end of set accessor End Property 'property side3 Public Property Side3() As Integer 'return m_intSide3 value Get Return m_intSide3 End Get 'end of Get accessor 'set m_intside3 value Set(ByVal Value As Integer) 'if side 3 value entered is valid If (Value > 0) Then m_intSide3 = Value Else m_intSide3 = 0 'set invalid input to 0 End If End Set 'end of set accessor End Property