ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 May 2017 My Price 8.00

A Squab is meant to represent a creature in a computer game

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

Answers

(11)
Status NEW Posted 26 May 2017 07:05 AM My Price 8.00

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-----------

Attachments

file 1651143765-Squab.docx preview (424 words )
S-----------qua-----------b.h-----------#if-----------nde-----------f S-----------QUA-----------B_H----------- #-----------def-----------ine----------- SQ-----------UAB-----------_H ----------- #i-----------ncl-----------ude----------- &q-----------uot-----------;po-----------sit-----------ion-----------.h&-----------quo-----------t; ----------- cl-----------ass----------- Sq-----------uab----------- { ----------- pr-----------iva-----------te:----------- ----------- -----------int----------- sc-----------ore-----------; ----------- ----------- Po-----------sit-----------ion----------- *p-----------os;----------- p-----------ubl-----------ic:----------- ----------- -----------Squ-----------ab(-----------int----------- x,----------- in-----------t y-----------); ----------- ----------- S-----------qua-----------b(c-----------ons-----------t S-----------qua-----------b &-----------amp-----------;am-----------p;o-----------bj)-----------; /-----------/ c-----------opy----------- co-----------nst-----------ruc-----------tor----------- ----------- -----------~Sq-----------uab-----------();----------- ----------- ----------- ----------- ----------- ----------- //----------- de-----------str-----------uct-----------or ----------- ----------- i-----------nt -----------get-----------Sco-----------re(-----------) c-----------ons-----------t; ----------- ----------- v-----------oid----------- in-----------cSc-----------ore-----------();----------- ----------- -----------Pos-----------iti-----------on -----------get-----------Pos-----------() -----------con-----------st;----------- ----------- -----------voi-----------d m-----------ove-----------(ch-----------ar -----------dn,----------- in-----------t d-----------e);----------- ----------- -----------boo-----------l l-----------ine-----------OfS-----------igh-----------t(S-----------qua-----------b s-----------) c-----------ons-----------t; ----------- ----------- S-----------qua-----------b *----------- cl-----------one-----------()
Not Rated(0)