I need help filling i the blanks for this code. I attatched the two problems the
ID: 3576389 • Letter: I
Question
I need help filling i the blanks for this code. I attatched the two problems they work together. It is in c#.
The following class defines a Rectangle object public class Rectanglet member variables (declare using proper OOP technique) double mLength, mWidth: private ReadOnly properties public double Length Length; Width public double mWidth. Constructor (Note: length is first parameter) public Rectangle(double double pLength pWidth //Method to calculate area public double CalculateArea() mLength mWidth:Explanation / Answer
Polymorphism :
=====================================================================================
At run time, objects of a derived class may be treated as objects of a base class in places such as method parameters and collections or arrays. When this occurs, the object's declared type is no longer identical to its run-time type.
=====================================================================================
// Read -only Properties
As these are Read-only properties, we will be returning the values ! Usually constructor is used to assign the values to the variables.
1. public double getLength() {
return mLength;
}
2. public double getWidth() {
return mWidth;
}
// Constructor
public Rectangle( double pLength ,double pwidth) {
mLength = pLength;
mWidth = pWidth;
}
// Method to calculate area
public double CalculateArea(){
return mLength*mWidth;
}
public class Box : rectangle
{
protected double mHeight;
public Box (double Length , double Width ,double Height ) : base (l,h,w)
{
mHeight = h;
}
}
Remaining part , I will leave as an exercise for you !
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.