The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Consider the following code defining a composition relationship between two classes:
A Squab is meant to represent a creature in a computer game that is played on a rectangular grid.
Positions on the grid are specified by two coordinates (x and y). Directions are represented by four
letters: N, S, E and W. Movement in direction E causes an increase in the x coordinate, and W a
decrease. Movement in direction N causes an increase in the y coordinate, and S a decrease
class Squab {
private:
int score;
Position pos;
public:
Squab(int x, int y);
int getScore() const;
void incScore();
Position getPos() const;
void move(char dn, int de);
bool lineOfSight(Squab s) const;
Squab * clone() const;
};
class Position {
private:
int x;
int y;
public:
Position(int x, int y);
void changePos(int x, int y);
int getX() const;
int getY() const;
};
A Squab is meant to represent a creature in a computer game that is played on a rectangular grid.
Positions on the grid are specified by two coordinates (x and y). Directions are represented by four
letters: N, S, E and W. Movement in direction E causes an increase in the x coordinate, and W a
decrease. Movement in direction N causes an increase in the y coordinate, and S a decrease
A S-----------qua-----------b i-----------s m-----------ean-----------t t-----------o r-----------epr-----------ese-----------nt -----------a c-----------rea-----------tur-----------e i-----------n a----------- co-----------mpu-----------ter----------- ga-----------me-----------