CPT 341 VB.NET Proiect 3 Calculating Centroids/Center of Gravity and Area Classe
ID: 3604002 • Letter: C
Question
CPT 341 VB.NET Proiect 3 Calculating Centroids/Center of Gravity and Area Classes, Objects, Methods, Properties, MenuStrip Control, PictureBox Control, Label Control of the 3 common shapes below: Rectange Right Triangle Circle The centroid of a square or rectangle is located at a distance of 1/2 its height and 12 ts base The centroid of a right tiangle is located at a distance of 1/3 its height and 1/3 its base Area reas (b)(h) Area -(b)(h) centroid (both cx and Cy) = r Area A D Sample VB Fom CPT 341-Classes & Objects Square Triangle Circle Exit The centroid of a square or rectangle is distance of 1/3 its height and 1/3 its base ocated at a distance of 1/2 its height and 1/2 ts base Input Values B H Height Square Centroid - Centroid m- Area- Triangle Centroid 00 Centroid m rea- Circle Centroid 00 Centroid (m Diameter Solution Explorer Project Notes . Create 3 Visual Basic Classes Include base, height and diameter properties Search Solution Explorer (Ctrl+:) o o Include functions for centroid and area (For example: Dim objRect as New cisRectangle) o Jpg images included in the project email/Moodle My Project Instantiate each class to create an Object Use a PictureBox control to display the shape image on the Form Display the solutions using Label controls App.config D B clsCircle.vb D VB clsRectangle.vb DVB clsTriangle.vb Form1.vb Include error handling where appropriateExplanation / Answer
Class clsShape
Protected Base As Integer
Protected Height As Integer
Protected Diameter As Integer
Public Sub setBase(ByVal b As Integer)
Base = b
End Sub
Public Sub setHeight(ByVal h As Integer)
Height = h
End Sub
Public Sub setDiameter(ByVal d As Integer)
Diameter = d
End Sub
End Class
Class clsSquare : Inherits clsShape
Public Function Area() As Integer
Return (Base * Height)
End Function
Public Function CentX() As Integer
Return (Base/2)
End Function
Public Function CentY() As Integer
Return (Height/2)
End Function
End Class
Class clsTriangle : Inherits clsShape
Public Function Area() As Integer
Return ((Base * Height)/2)
End Function
Public Function CentX() As Integer
Return (Base/3)
End Function
Public Function CentY() As Integer
Return (Height/3)
End Function
End Class
Class clsCircle : Inherits clsShape
Public Function Area() As Integer
Return ((22/7)*(Diameter/2))
End Function
Public Function CentX() As Integer
Return (Diameter/2))
End Function
Public Function CentY() As Integer
Return (Diameter/2))
End Function
End Class
Class ShapeTest
Shared Sub Main()
Dim objSquare As clsSquare = New clsSquare()
objSquare.setBase(10);
objSquare.setHeight(10);
objSquare.Area();
objSquare.CentX();
objSquare.CentY();
Dim objTriangle As clsTriangle = New clsTriangle()
objTriangle.setBase(10);
objTriangle.setHeight(5);
objTriangle.Area();
objTriangle.CentX();
objTriangle.CentY();
Dim objCircle As clsCircle = New clsCircle()
objCircle.setDiameter(10);
objCircle.Area();
objCircle.CentX();
objCircle.CentY();
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.