Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2: Write a C++ program and algorithm for a class inheritance game where

ID: 3698726 • Letter: P

Question

Problem 2: Write a C++ program and algorithm for a class inheritance game where a kitten with random position in the gameboard is to be caught by its mother cat whose initial position is center to board and speed to particular direction a little higher than the kitten. The class member functions include a draw function where the mother cat stays at the middle. The direction is measured by the input function when say press '4' means LEFT, '6' means RIGHT, ‘8' means UP, ‘2' means DOWN and 's' means STOP. Use a score as the mother cat catches her kitten. Change the coordinates of the kitten and mother cat to zero, if they touch the wall. (Marks 30) Note: Use #include-conio.h> for console I/O and functions kbhit() which returns true if key board is pressed and getchO which returns ASCII value of the key pressed

Explanation / Answer

EDITABLE CODE:

class Game {

private:

int color;

public:

void driveAtFullSpeed(int mph){

// code for moving the car ahead

}

};

class Gameplanner {

private:

int color;

bool sirenOn; // identifies whether the siren is on or not

bool inAction; // identifies whether the police is in action (following the player) or not

public:

bool isInAction(){

return this->inAction;

}

void driveAtFullSpeed(int mph){

// code for moving the car ahead

}

};

class Car {

protected:

int color;

int currentSpeed;

int maxSpeed;

public:

void applyHandBrake(){

this->currentSpeed = 0;

}

void pressHorn(){

cout << "Teeeeeeeeeeeeent"; // funny noise for a horn

}

void driveAtFullSpeed(int mph){

// code for moving the car ahead;

}

};

class Game : public Car {

};

class Gameplanner : public Car {

private:

bool sirenOn; // identifies whether the siren is on or not

bool inAction; // identifies whether the police is in action (following the player) or not

public:

bool isInAction(){

return this->inAction;

}

};

class Form {

private:

double area;

public:

int color;

double getArea(){

return this->area;

}

void setArea(double area){

this->area = area;

}

};

class Circle : public Form {

public:

double getRatio() {

double a;

a = getArea();

return sqrt(a / 2 * 3.14);

}

void setRatio(double diameter) {

setArea( pow(diameter 0.5, 2) 3.14 );

}

bool isDark() {

return (color > 10);

}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote