Mar 19, 2010 at 1:28am UTC
#include <string>
#include <cmath>
#include "ccc_win.h"
using namespace std;
//define the Rectangle class
class Rectangle
{
public:
//constructor
Rectangle(Point p, Point q);
//accessor
void plot() const;
//mutator
void move(double dx, double dy);
private:
Point a, b;
};
double perimeter (Rectangle r);
double area (Rectangle r);
int ccc_win_main()
{
Rectangle rect( Point(0, 3), Point(5, 0) );
rect.plot();
rect.move( -3, -2 );
rect.plot();
double length = rwin.get_double(
"Please enter the length of the rectangle" );
double width = rwin.get_double(
"Please enter the width of the rectangle");
double height = rwin.get_double (
"Please enter the height of the rectangle");
double base = rwin.get_double (
"Please enter the base of the rectangle");
Rectangle r(
return 0;
}
double perimeter(Rectangle r)
{
double length = r.get_length();
double width = r.get_width ();
double perim = 2 * ( length + width);
return perim;
}
double area(Rectangle r)
{
double base = r.get_base();
double height = r.get_height();
double are = base * height;
return are;
}
//implement the Retangle class
//constructor
Rectangle::Rectangle(Point p, Point q) :
a(p.get_x(), p.get_y()),
b(q.get_x(), q.get_y())
{
//nada
}
//accessor
void Rectangle::plot() const
{
//find the other corner points
Point ax_by = Point( a.get_x(), b.get_y() );
Point ay_bx = Point( b.get_x(), a.get_y() );
//display the four lines
cwin << Line( a, ax_by );
cwin << Line( a, ay_bx );
cwin << Line( ax_by, b );
cwin << Line( ay_bx, b );
}
//mutator
void Rectangle::move(double dx, double dy)
{
a.move(dx, dy);
b.move(dx, dy);
}
Can anyone tell me what i am doing wrong? and what needs to be done?