Hey guys, I am having trouble building this class, my teacher is not very helpful. Here is the code I have been working on, I am still confused on methods, constuctors, properties, etc. He gave me a wierd example to try to follow. Here are the requirements my teacher wants as well as the code:
. Design a class named Rectangle to represent a rectangle. The class contains:
• Two double data fields named dblwidth and dblheight that specify the width and height of the rectangle. The default values are 1 for both dblwidth and dblheight.
• A string data field named strcolor that specifies the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.
• A no parameter constructor will be created which represents the default rectangle.
• A three parameter (width, length, color) will be created.
• Three properties (width, length, and color) will be created.
• A method named getArea() will be created to find the area (area = width * length).
• A method named getPerimeter() will be created to find the perimeter (perimeter = 2 * width + 2 * length).
Write a test program in Windows that asks for the width, length and color of a rectangle and find the area and perimeter.
Public Class Rectangle Private dblWidth As Double Private dblHeight As Double Private strColor As String Public Sub New(ByVal vwidth As Integer, _ ByVal vlength As Integer, _ ByVal vcolor As String) width = vwidth length = vlength color = vcolor End Sub Public Property width() As Integer Get Return dblWidth() End Get Set(ByVal value As Integer) dblWidth = value End Set End Property Public Property length() As Integer Get Return End Get Set(ByVal value As Integer) End Set End Property Public Property color() As String Get End Get Set(ByVal value As Integer) End Set End Property Public Sub getArea() Dim area As Integer = width * length End Sub Public Sub getPerimeter() Dim perimeter As Integer = (2 * width) + (2 + length) End Sub End Class