Week 01 Lab 01 Rectangle
Week 01 Lab 01 Rectangle
This exercise comprises of two parts that is implemented in two separate projects.
Part I
This first design is a poor one for many reasons that we will see later in this lab and in this course.
Method: CreateRectangle()
Name: CreateRectangle
Returns: A BadRectangle object
Argument: int representing the width, int representing the length
Action:
Creates a BadRectangle object with the new operator
The dot operator allows to you
Set the width and length as specified by the arguments
access members of a type.
Return the object created
Method: DescribeRectangle()
Name: DescribeRectangle
Page 1 of 4
Programming II Methods that works with Rectangle class
Returns: void
Argument: BadRectangle object
Action: Displays the width and length of the Rectangle object
Method: CalculateAndDisplayArea()
Name: CalculateAndDisplayArea
Returns: void
Argument: BadRectangle object
Action:
Calculate the area of the rectangle object represented by the formula (length x width).
Display the result of the above computation.
Part II
This design is a better one because we will fix the above design flaws and make the class easier to use.
Page 2 of 4
Programming II Methods that works with Rectangle class
Page 3 of 4
Programming II Methods that works with Rectangle class
Page 4 of 4