my_point
Jul 18, 2011 at 11:40pm Jul 18, 2011 at 11:40pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include <iostream>
#include <math.h>
using namespace std;
class my_point
{
public :
my_point();
my _point (int ,int );
void print()const ;
int getX ()const ;
int getY ()const ;
void setX (int );
void setY (int );
double distance (my_point);
//new methods to add
void moveNE (int ,int );
bool inFirstQuadrant()const ;
bool inSecondQuadrant ()const ;
bool inThirdQuadrant ()const ;
bool inFourthQuadrant ()const ;
bool inSameQuadrant (my_point)cosnt;
double signedArea (my_point,my_point) const ;
double triangleArea (my_point,my_point)const ;
bool leftTurn (my-point,my_point)cosnt;
bool collinear (my_point,my_point)const ;
bool rightTurn (my_point,my_point)const ;
private :
int xCoord;
int yCoord;
};
void my_point::moveNE(int n1, int n2)
//
//
{
n1=xCoord;
n2=ycoord;
}
trying to figure out void moveNE. is intended to move point object in the north-east direction by adding n1 to the x-coord and adding n2 to y-coord of th e point . it is assumed that the value of n1 and n2 are both greater than zero. for example if my_point object p1 is (10,10) then p1.moveNE(1,2) should make the coodinates of p1 as (11,12)
Jul 18, 2011 at 11:53pm Jul 18, 2011 at 11:53pm UTC
Why not just add n1 to the yCoord and n2 to the xCoord?
Topic archived. No new replies allowed.