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

Could help getting started on this problem or an example to go by. Write a C++ p

ID: 3859440 • Letter: C

Question

Could help getting started on this problem or an example to go by.

Write a C++ program and algorithm for a class inheritance game where a small fish with random position and direction is eaten by a larger fish initial position center to board and direction speed a little higher than the small fish. The class member functions include a draw function where the big fish 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 function as the big fish eats (both coordinates same) the small fish. Also put the small fish into random position each time Big Fish eats the small fish. Change the coordinates of fish if they touch the wall.

Note: Use #include<conio.h> for console I/O and functions kbhit() which returns true if key board is pressed and getch() which returns ASCII value of the key pressed.

Thanks,

CW

Explanation / Answer

class fish {
private:
int color;
  
public:
void driveAtFullSpeed(int mph){
// code for moving the fishcolor ahead
}
};

class smalfish {
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 fishcolor ahead
}
  
};
class fishcolor {
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 fishcolor ahead;
}
};

class fish : public fishcolor {

};

class smalfish : public fishcolor {
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;
}
};
lass 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);
}

};