Project 03
Home ] Up ]

 

CSIS 250 Fall 2000 Project #3

 

Date Assigned

October 02, 2000

Date Due

October 11, 2000

Add the following function members to the CPoint class in the point00.cpp program file.

function/operator

Description

bool operator == (const CPoint &p) const;

Overloads the equality operator

bool operator != (const CPoint &p) const;

Overloads the inequality operator

CPoint operator -(void);

Overloads the unary minus operator

double distanceFrom(const CPoint &p) const;

Returns the distance of a point from another point

Submit the well-documented printed source code and sample output.  Provide at least five test cases for each function.  Clearly show the operands and the results from each function.  Also complete and submit the following self-evaluation table. 

SELF-EVALUATION SHEET

Function

Well Documented Working Functions

Properly Labeled Sample Runs

 

Maximum Score

Your Score

Maximum Score

Your Score

operator ==

10

 

10

 

operator !=

10

 

10

 

operator -

10

 

10

 

distanceFrom

10

 

10

 

Subtotal

40

 

40

 

Total Score

80

 

 

Use the following class definition:

//class definition

////////////////////////////////////////////////////////////

class CPoint

  {

  private:

    int x;

    int y;

  public:

    CPoint (int a=0, int b=0);

    CPoint (char ch);

    void display(void) const;

    void setX (int a);

    void setY (int b);

    void setXY (int a, int b);

    int getX(void) const;

    int getY(void) const;

    void getXY (int &a, int &b) const;

    void copyTo (CPoint &p) const;

    void copyFrom (const CPoint &p);

    bool isEqualTo (const CPoint &p) const;

 

    bool operator == (const CPoint &p) const;

    bool operator != (const CPoint &p) const;

    CPoint operator -(void);

    double distanceFrom(const CPoint &p1) const;

  };