Help on an assigment! Hey guys I\'ve done a little bit of the work but I need so
ID: 3786512 • Letter: H
Question
Help on an assigment! Hey guys I've done a little bit of the work but I need some assistance on this c++ assignment
The project is a C++ program that utilizes classes and inheritance
to model geometric shapes
I've figured out the main.cpp format and have Specification file of the triangle, rectangle and color completed. I also have the shape implementation file completed but not the specification file. apparently I am not allowed to change any #include stuff, any help is appreciated! Thank you so much ((so in short triangle.h, rectangle.h, color.h, shape.cpp, and main.cpp are COMPLETED// triangle.cpp, rectangle.cpp, color.cpp, and shape.h are NOT COMPLETED))
Here is the main.cpp file
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// main.cpp
//
// Driver program which is used to test each
// class member function.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <typeinfo>
#include "color.h"
#include "shape.h"
#include "triangle.h"
#include "rectangle.h"
using namespace std; // Global using declaration
// Prototypes for support functions -- definitions appear after main()
void Bar(int n); // Prototype for Bar function
void Print(Shape* someShape); // Prototype for Print function
//void PrintColor(Color someColor); // Prototype for PrintColor function
// Start of main() function
int main (int argc, char* const argv[]) // Command-line arguments (more on this later)
{
ifstream inputs; // Input file stream variable for test file
char op, ch; // Hold operation and optional char input from test file
Shape* ptr = NULL; // Pointer to abstract shape object
string operand1,operand2,operand3,operand4; // Holds operand values input from test file
string comment; // Holds comment input from test file
Color someColor; // Holds color input from file
char t; // Holds s for Shape, t/T for Triangle, r/R for Rectangle
double a, b, c; // Holds lengths a, b, c input from file
int red, green, blue; // Holds red, green, blue input from file
Color* color;
// Output usage message if test input file name is not provided
if (argc != 2)
{
cout << "Usage: project02 <inputfile> ";
return 1;
}
// Attempt to open test input file -- terminate if file does not open
inputs.open(argv[1]);
if (!inputs)
{
cout << "Error - unable to open input file" << endl;
return 1;
}
Bar(60); // Output long bar
// Process comment line from input file
getline(inputs, comment); // Input file header comment
cout << endl << comment << endl << endl; // Output file header comment
// Configure floating point decimal output
cout << fixed << showpoint << setprecision(2);
// Below is the primary loop that processes each operation appearing within the test file.
// Starts with an initial priming read of first operation
inputs >> op; // Attempt to input first test operation from file
while (inputs) // While Not-EOF
{
switch (op) // Process operation input from test file
{
case '#': // Test file comment
getline(inputs, comment); // Input and echo the comment appearing in the test file
cout << '#' << comment << endl;
break;
case '?': // Print Operator
cout << "TypeID -- ";
Print(ptr);
break;
case '~': // Print Bar
Bar(40); // Output short bar
break;
case '+': // Use symbol input from file to invoke appropriate constructor
inputs >> t; // Input object type symbol
try
{
cout << "Constructor -- ";
switch (t)
{
case 's': // Shape default constructor
cout << "Shape() ";
ptr = new Shape();
break;
case 'S': // Shape parameterized constructor
inputs >> red >> green >> blue;
cout << "Shape(" << red << "," << green << "," << blue << ") ";
ptr = new Shape(red,green,blue);
break;
case 't': // Triangle default constructor
cout << "Triangle() ";
ptr = new Triangle;
break;
case 'T': // Triangle parameterized constructor
inputs >> a >> b >> c >> red >> green >> blue;
cout << "Triangle(" << a << ", " << b << ", "
<< c << ", " << red << ", " << green << ", " << blue << ") ";
ptr = new Triangle(a, b, c, red, green, blue);
break;
case 'r': // Rectangle default constructor
cout << "Rectangle() ";
ptr = new Rectangle;
break;
case 'R': // Rectangle parameterized constructor
inputs >> a >> b >> red >> green >> blue;
cout << "Rectangle(" << a << ", " << b << ", "
<< red << ", " << green << ", " << blue << ") ";
ptr = new Rectangle(a, b, red, green, blue);
break;
default: cout << "Error: unrecognized object" << endl;
} // End switch (op)
cout << "Completed";
} // End try
catch ( ... ) // Catch any exception thrown above
{
cout << "Failed";
}
cout << endl;
break;
case 'c': // getColor()
cout << "getColor() -- ";
try
{
ptr->getColor().print();
cout << " Completed";
}
catch ( ... )
{
cout << "Failed";
}
cout << endl;
break;
case 'a': // area(...)
//inputs >> operand1;
cout << "area() -- ";
try
{
cout << ptr->area();
}
catch ( ... )
{
cout << "Failed";
}
cout << endl;
break;
case 'p': // perimeter(...)
//inputs >> operand1;
cout << "perimeter() -- ";
try
{
cout << ptr->perimeter();
}
catch ( ... )
{
cout << "Failed";
}
cout << endl;
break;
case '-': // Destructor
try
{
cout << "Destructor -- ";
delete ptr; // Deallocate currency
cout << "Completed";
ptr = NULL; // Make sure that ptr is not a dangling pointer
}
catch ( ... )
{
cout << "Failed";
}
cout << endl << endl;
break;
default: // Error
cout << "Error - unrecognized operation '" << op << "'" << endl;
cout << "Terminating now..." << endl;
return 1;
break;
}
inputs >> op; // Attempt to input next command
}
cout << endl;
Bar(60); // Output long bar
return 0;
}
void Bar(int n)
// Bar() -- prints horizontal bar
{
for(int k = 0; k < n; k++)
cout << '#';
cout << endl;
} // End Bar()
void Print(Shape* someShape)
// Writes shape object description to stdout
{
string s = typeid(*someShape).name();
cout << s << endl;
}
/************** End of main.cpp ***************/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Okay now here are the specification files (besides the shape.h while I need to complete)
///////////////////////////////
// color.h
//
// Color class models the color of an item <red,green,blue>
//
// Use the contents of this file to implement color.cpp
#include <iostream>
using namespace std;
#ifndef COLOR_H
#define COLOR_H
class Color
{
private:
int red; // Amount of red 0-255
int green; // Amount of green 0-255
int blue; // Amount of blue 0-255
public:
Color(); // Initializes red, green, and blue to zero
void setRed(int rr); // Sets red to rr
void setGreen(int gg); // Sets green to gg
void setBlue(int bb); // Sets blue to bb
int getRed() const; // Returns red
int getGreen() const; // Returns green
int getBlue() const; // Returns blue
void print() const // Writes <red,green,blue> to std output
{
cout << "<" << getRed() << "," << getGreen() << "," << getBlue() << ">";
}
};
#endif
////////////////////////////////////////////////////////////////
// rectangle.h
//
// Rectangle class models Rectangle with side lengths l, w
//
// Use the contents of this file to implement rectangle.cpp
//
#include "shape.h"
#ifndef RECTANGLE_H
#define RECTANGLE_H
class Rectangle : public Shape
{
private:
double l, w; // Side lengths
public:
Rectangle(); // Initializes l, w to 0.0 and red, green, blue to 0
Rectangle(double ll, double ww, // Initializes l, w to ll, ww and
int rr, int gg, int bb); // red, green, blue to rr, gg, bb respectively
double area() const; // Returns area value computed from l, w
double perimeter() const; // Returns perimeter value computed from l, w
};
#endif
//////////////////////////////////////////////////////
//
// triangle.h
//
// Triangle class models triangle with side lengths a, b, c
//
// Use the contents of this file to implement triangle.cpp
#include "shape.h"
#ifndef TRIANGLE_H
#define TRIANGLE_H
class Triangle : public Shape
{
private:
double a, b, c; // Side lengths
public:
Triangle(); // Initializes a, b, c to 0.0 and red, green, blue to 0
Triangle(double aaa, double bbb, double ccc, // Initializes a, b, c to aaa, bbb, ccc and
int rr, int gg, int bb); // red, green, blue to rr, gg, bb respectively
double area() const; // Returns area value computed from a, b, c
double perimeter() const; // Returns perimeter value computed from a, b, c
};
#endif
//////////////////////////////////////////////////
And here is the shape implementation file that I have (in which I need the .h specification file for)
////////////////////////////////////////////////////
// shape.cpp
//
// Shape class models a generic geometric shape with color
// defined by a private Color object attribute c
//
// Use the contents of this file to reverse engineer the contents of shape.h
//
#include "shape.h"
Shape::Shape()
// Initializes c to <0,0,0>
{
c = Color();
}
Shape::Shape(int r, int g, int b)
// Initializes c to <r,g,b>
{
c.setRed(r);
c.setGreen(g);
c.setBlue(b);
}
Color Shape::getColor() const
// Returns color of object
{
return c;
}
double Shape::area() const
// Returns default area of 0.0 -- polymorphic function
{
return 0.0;
}
double Shape::perimeter() const
// Returns default perimeter of -1.0 -- polymorphic function
{
return -1.0;
}
////////////////////////////////////////////////////////
THESE ARE THE INPUT FILES THAT WILL BE RUN THROUGH THE PROGRAM
////////////////////////////////////////////////////////
# p02input1.txt - Test Shape class
# Test default constructor
+ s
?
-
# Test parameterized constructor
+ S 1 2 3
?
-
# Test area() and perimeter() with default constructor
+ s
?
a
p
-
# Test area() and perimeter() with parameterized constructor
+ S 1 2 3
?
a
p
-
# Test getColor() with default constructor
+ s
?
c
-
# Test getColor() parameterized constructor
+ S 1 2 3
?
c
-
///////
# p02input1.txt - Test Triangle class
# Test default constructor
+ t
?
-
# Test parameterized constructor
+ T 3 4 5 128 256 0
?
-
# Test area() and perimeter() with default constructor
+ t
?
a
p
-
# Test area() and perimeter() with parameterized constructor
+ T 3 4 5 128 256 0
?
a
p
-
# Test getColor() with default constructor
+ t
?
c
-
# Test getColor() parameterized constructor
+ T 3 4 5 128 256 0
?
c
-
///////////////
# p02input1.txt - Test Rectangle class
# Test default constructor
+ r
?
-
# Test parameterized constructor
+ R 3 5 0 128 256
?
-
# Test getColor() with default constructor
+ r
?
c
-
# Test getColor() with parameterized constructor
+ R 3 5 0 128 256
?
c
-
# Test area() and perimeter() with default constructor
+ r
?
a
p
-
# Test area() and perimeter() with parameterized constructor
+ R 3 5 0 128 256
?
a
p
-
Explanation / Answer
Hi,
I'm pasting code for all the files here. And also i have mentioned how to compile and execute the code.
color.h
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Okay now here are the specification files (besides the shape.h while I need to complete)
///////////////////////////////
// color.h
//
// Color class models the color of an item <red,green,blue>
//
// Use the contents of this file to implement color.cpp
#include <iostream>
using namespace std;
#ifndef COLOR_H
#define COLOR_H
class Color
{
private:
int red; // Amount of red 0-255
int green; // Amount of green 0-255
int blue; // Amount of blue 0-255
public:
Color(); // Initializes red, green, and blue to zero
void setRed(int rr); // Sets red to rr
void setGreen(int gg); // Sets green to gg
void setBlue(int bb); // Sets blue to bb
int getRed() const; // Returns red
int getGreen() const; // Returns green
int getBlue() const; // Returns blue
void print() const // Writes <red,green,blue> to std output
{
cout << "<" << getRed() << "," << getGreen() << "," << getBlue() << ">";
}
};
#endif
shape.h
#include<iostream>
using namespace std;
#ifndef SHAPE_H_
#define SHAPE_H_
#include "color.h"
class Shape{
Color c;
public:
Shape();
Shape(int,int ,int);
Color getColor() const;
double area() const;
double perimeter() const;
};
#endif
rectangle.h
////////////////////////////////////////////////////////////////
// rectangle.h
//
// Rectangle class models Rectangle with side lengths l, w
//
// Use the contents of this file to implement rectangle.cpp
//
#include "shape.h"
#ifndef RECTANGLE_H
#define RECTANGLE_H
class Rectangle : public Shape
{
private:
double l, w; // Side lengths
public:
Rectangle(); // Initializes l, w to 0.0 and red, green, blue to 0
Rectangle(double ll, double ww, // Initializes l, w to ll, ww and
int rr, int gg, int bb); // red, green, blue to rr, gg, bb respectively
double area() const; // Returns area value computed from l, w
double perimeter() const; // Returns perimeter value computed from l, w
};
#endif
triangle.h
//////////////////////////////////////////////////////
//
// triangle.h
//
// Triangle class models triangle with side lengths a, b, c
//
// Use the contents of this file to implement triangle.cpp
#include "shape.h"
#ifndef TRIANGLE_H
#define TRIANGLE_H
class Triangle : public Shape
{
private:
double a, b, c; // Side lengths
public:
Triangle(); // Initializes a, b, c to 0.0 and red, green, blue to 0
Triangle(double aaa, double bbb, double ccc, // Initializes a, b, c to aaa, bbb, ccc and
int rr, int gg, int bb); // red, green, blue to rr, gg, bb respectively
double area() const; // Returns area value computed from a, b, c
double perimeter() const; // Returns perimeter value computed from a, b, c
};
#endif
color.cpp
#include "color.h"
Color::Color()
{
red=green=blue=0;
}
void Color::setRed(int r) { red=r;}
void Color::setGreen(int g) { green=g;}
void Color::setBlue(int b) { blue=b;}
int Color::getRed() const { return red;}
int Color::getGreen() const { return green;}
int Color::getBlue() const { return blue;}
rectangle.cpp
#include "rectangle.h"
#include<math.h>
Rectangle::Rectangle() { l=w=0;}
Rectangle::Rectangle(double ll,double ww, int r,int g,int b):Shape(r,g,b)
{
l=ll;w=ww;
}
double Rectangle::area() const {
return l*w;
}
double Rectangle::perimeter() const {
return 2*(l+w);
}
shape.cpp
//////////////////////////////////////////////////
//And here is the shape implementation file that I have (in which I need the .h specification file for)
////////////////////////////////////////////////////
// shape.cpp
//
// Shape class models a generic geometric shape with color
// defined by a private Color object attribute c
//
// Use the contents of this file to reverse engineer the contents of shape.h
//
#include "shape.h"
Shape::Shape()
// Initializes c to <0,0,0>
{
c = Color();
}
Shape::Shape(int r, int g, int b)
// Initializes c to <r,g,b>
{
c.setRed(r);
c.setGreen(g);
c.setBlue(b);
}
Color Shape::getColor() const
// Returns color of object
{
return c;
}
double Shape::area() const
// Returns default area of 0.0 -- polymorphic function
{
return 0.0;
}
double Shape::perimeter() const
// Returns default perimeter of -1.0 -- polymorphic function
{
return -1.0;
}
triangle.cpp
To compute area i have used sqrt(s(s-a)(s-b)(s-c)
#include "triangle.h"
#include<math.h>
Triangle::Triangle(){ a=b=c=0;}
Triangle::Triangle(double aa,double bb,double cc,int r,int g,int b):Shape(r,g,b)
{
a=aa;b=bb;c=cc;
}
double Triangle::area() const {
double s=(a+b+c)/2;
double area=sqrt(s * (s-a) * (s-b) * (s-c));
return area;
}
double Triangle::perimeter() const {
return (a+b+c);
}
main.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// main.cpp
//
// Driver program which is used to test each
// class member function.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <typeinfo>
#include "color.h"
#include "shape.h"
#include "triangle.h"
#include "rectangle.h"
using namespace std; // Global using declaration
// Prototypes for support functions -- definitions appear after main()
void Bar(int n); // Prototype for Bar function
void Print(Shape* someShape); // Prototype for Print function
//void PrintColor(Color someColor); // Prototype for PrintColor function
// Start of main() function
int main (int argc, char* const argv[]) // Command-line arguments (more on this later)
{
ifstream inputs; // Input file stream variable for test file
char op, ch; // Hold operation and optional char input from test file
Shape* ptr = NULL; // Pointer to abstract shape object
string operand1,operand2,operand3,operand4; // Holds operand values input from test file
string comment; // Holds comment input from test file
Color someColor; // Holds color input from file
char t; // Holds s for Shape, t/T for Triangle, r/R for Rectangle
double a, b, c; // Holds lengths a, b, c input from file
int red, green, blue; // Holds red, green, blue input from file
Color* color;
// Output usage message if test input file name is not provided
if (argc != 2)
{
cout << "Usage: project02 <inputfile> ";
return 1;
}
// Attempt to open test input file -- terminate if file does not open
inputs.open(argv[1]);
if (!inputs)
{
cout << "Error - unable to open input file" << endl;
return 1;
}
Bar(60); // Output long bar
// Process comment line from input file
getline(inputs, comment); // Input file header comment
cout << endl << comment << endl << endl; // Output file header comment
// Configure floating point decimal output
cout << fixed << showpoint << setprecision(2);
// Below is the primary loop that processes each operation appearing within the test file.
// Starts with an initial priming read of first operation
inputs >> op; // Attempt to input first test operation from file
while (inputs) // While Not-EOF
{
switch (op) // Process operation input from test file
{
case '#': // Test file comment
getline(inputs, comment); // Input and echo the comment appearing in the test file
cout << '#' << comment << endl;
break;
case '?': // Print Operator
cout << "TypeID -- ";
Print(ptr);
break;
case '~': // Print Bar
Bar(40); // Output short bar
break;
case '+': // Use symbol input from file to invoke appropriate constructor
inputs >> t; // Input object type symbol
try
{
cout << "Constructor -- ";
switch (t)
{
case 's': // Shape default constructor
cout << "Shape() ";
ptr = new Shape();
break;
case 'S': // Shape parameterized constructor
inputs >> red >> green >> blue;
cout << "Shape(" << red << "," << green << "," << blue << ") ";
ptr = new Shape(red,green,blue);
break;
case 't': // Triangle default constructor
cout << "Triangle() ";
ptr = new Triangle;
break;
case 'T': // Triangle parameterized constructor
inputs >> a >> b >> c >> red >> green >> blue;
cout << "Triangle(" << a << ", " << b << ", "
<< c << ", " << red << ", " << green << ", " << blue << ") ";
ptr = new Triangle(a, b, c, red, green, blue);
break;
case 'r': // Rectangle default constructor
cout << "Rectangle() ";
ptr = new Rectangle;
break;
case 'R': // Rectangle parameterized constructor
inputs >> a >> b >> red >> green >> blue;
cout << "Rectangle(" << a << ", " << b << ", "
<< red << ", " << green << ", " << blue << ") ";
ptr = new Rectangle(a, b, red, green, blue);
break;
default: cout << "Error: unrecognized object" << endl;
} // End switch (op)
cout << "Completed";
} // End try
catch ( ... ) // Catch any exception thrown above
{
cout << "Failed";
}
cout << endl;
break;
case 'c': // getColor()
cout << "getColor() -- ";
try
{
ptr->getColor().print();
cout << " Completed";
}
catch ( ... )
{
cout << "Failed";
}
cout << endl;
break;
case 'a': // area(...)
//inputs >> operand1;
cout << "area() -- ";
try
{
cout << ptr->area();
}
catch ( ... )
{
cout << "Failed";
}
cout << endl;
break;
case 'p': // perimeter(...)
//inputs >> operand1;
cout << "perimeter() -- ";
try
{
cout << ptr->perimeter();
}
catch ( ... )
{
cout << "Failed";
}
cout << endl;
break;
case '-': // Destructor
try
{
cout << "Destructor -- ";
delete ptr; // Deallocate currency
cout << "Completed";
ptr = NULL; // Make sure that ptr is not a dangling pointer
}
catch ( ... )
{
cout << "Failed";
}
cout << endl << endl;
break;
default: // Error
cout << "Error - unrecognized operation '" << op << "'" << endl;
cout << "Terminating now..." << endl;
return 1;
break;
}
inputs >> op; // Attempt to input next command
}
cout << endl;
Bar(60); // Output long bar
return 0;
}
void Bar(int n)
// Bar() -- prints horizontal bar
{
for(int k = 0; k < n; k++)
cout << '#';
cout << endl;
} // End Bar()
void Print(Shape* someShape)
// Writes shape object description to stdout
{
string s = typeid(*someShape).name();
cout << s << endl;
}
/************** End of main.cpp ***************/
input file : input.txt
# p02input1.txt - Test Shape class
# Test default constructor
+ s
?
-
# Test parameterized constructor
+ S 1 2 3
?
-
# Test area() and perimeter() with default constructor
+ s
?
a
p
-
# Test area() and perimeter() with parameterized constructor
+ S 1 2 3
?
a
p
-
# Test getColor() with default constructor
+ s
?
c
-
# Test getColor() parameterized constructor
+ S 1 2 3
?
c
-
# p02input1.txt - Test Triangle class
# Test default constructor
+ t
?
-
# Test parameterized constructor
+ T 3 4 5 128 256 0
?
-
# Test area() and perimeter() with default constructor
+ t
?
a
p
-
# Test area() and perimeter() with parameterized constructor
+ T 3 4 5 128 256 0
?
a
p
-
# Test getColor() with default constructor
+ t
?
c
-
# Test getColor() parameterized constructor
+ T 3 4 5 128 256 0
?
c
-
# p02input1.txt - Test Rectangle class
# Test default constructor
+ r
?
-
# Test parameterized constructor
+ R 3 5 0 128 256
?
-
# Test getColor() with default constructor
+ r
?
c
-
# Test getColor() with parameterized constructor
+ R 3 5 0 128 256
?
c
-
# Test area() and perimeter() with default constructor
+ r
?
a
p
-
# Test area() and perimeter() with parameterized constructor
+ R 3 5 0 128 256
?
a
p
-
Output:
$ g++ main.cpp rectangle.cpp triangle.cpp shape.cpp color.cpp
$ ./a.out input.txt
############################################################
# p02input1.txt - Test Shape class
# Test default constructor
Constructor -- Shape() Completed
TypeID -- 5Shape
Destructor -- Completed
# Test parameterized constructor
Constructor -- Shape(1,2,3) Completed
TypeID -- 5Shape
Destructor -- Completed
# Test area() and perimeter() with default constructor
Constructor -- Shape() Completed
TypeID -- 5Shape
area() -- 0.00
perimeter() -- -1.00
Destructor -- Completed
# Test area() and perimeter() with parameterized constructor
Constructor -- Shape(1,2,3) Completed
TypeID -- 5Shape
area() -- 0.00
perimeter() -- -1.00
Destructor -- Completed
# Test getColor() with default constructor
Constructor -- Shape() Completed
TypeID -- 5Shape
getColor() -- <0,0,0> Completed
Destructor -- Completed
# Test getColor() parameterized constructor
Constructor -- Shape(1,2,3) Completed
TypeID -- 5Shape
getColor() -- <1,2,3> Completed
Destructor -- Completed
# p02input1.txt - Test Triangle class
# Test default constructor
Constructor -- Triangle() Completed
TypeID -- 5Shape
Destructor -- Completed
# Test parameterized constructor
Constructor -- Triangle(3.00, 4.00, 5.00, 128, 256, 0) Completed
TypeID -- 5Shape
Destructor -- Completed
# Test area() and perimeter() with default constructor
Constructor -- Triangle() Completed
TypeID -- 5Shape
area() -- 0.00
perimeter() -- -1.00
Destructor -- Completed
# Test area() and perimeter() with parameterized constructor
Constructor -- Triangle(3.00, 4.00, 5.00, 128, 256, 0) Completed
TypeID -- 5Shape
area() -- 0.00
perimeter() -- -1.00
Destructor -- Completed
# Test getColor() with default constructor
Constructor -- Triangle() Completed
TypeID -- 5Shape
getColor() -- <0,0,0> Completed
Destructor -- Completed
# Test getColor() parameterized constructor
Constructor -- Triangle(3.00, 4.00, 5.00, 128, 256, 0) Completed
TypeID -- 5Shape
getColor() -- <128,256,0> Completed
Destructor -- Completed
# p02input1.txt - Test Rectangle class
# Test default constructor
Constructor -- Rectangle() Completed
TypeID -- 5Shape
Destructor -- Completed
# Test parameterized constructor
Constructor -- Rectangle(3.00, 5.00, 0, 128, 256) Completed
TypeID -- 5Shape
Destructor -- Completed
# Test getColor() with default constructor
Constructor -- Rectangle() Completed
TypeID -- 5Shape
getColor() -- <0,0,0> Completed
Destructor -- Completed
# Test getColor() with parameterized constructor
Constructor -- Rectangle(3.00, 5.00, 0, 128, 256) Completed
TypeID -- 5Shape
getColor() -- <0,128,256> Completed
Destructor -- Completed
# Test area() and perimeter() with default constructor
Constructor -- Rectangle() Completed
TypeID -- 5Shape
area() -- 0.00
perimeter() -- -1.00
Destructor -- Completed
# Test area() and perimeter() with parameterized constructor
Constructor -- Rectangle(3.00, 5.00, 0, 128, 256) Completed
TypeID -- 5Shape
area() -- 0.00
perimeter() -- -1.00
Destructor -- Completed
############################################################
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.