Inheritance and getting started

I was given an assignment and am very confused not only on exactly is being asked, but how to get started. We were given the starting code and it does compile. We have to use inheritance and create an object to meet certain parameters and can alter the starting code. I'm just not quite sure how to start(I am developmentally challenged when it comes to C++). Here's the code and parameters.
Parameters:
For the final program you will create a “pick up” game. What you pick up is up to you. In my program I wrote it to pickup “coins”. (So for the rest of this document you will see me refer to coins but you can use anything else that you want to.)

you MUST drop anywhere from 1 to 10 coins. You MUST also get a random number from 1 to 10 for how many coins you will put in the grid, then loop for as many cookies you are going to put into the grid, getting a random height and random width for the location to put that coin into the grid. Before putting the coin in the grid, you MUST check to see if there is already a coin there or if the user’s cursor is in that spot. If that spot is already a coin or the user’s cursor then you MUST get another random height and width and try to put the coin there.

Another requirement of this assignment is that you MUST check to make sure that the user does not go out of the bounds of your grid. This will require you to check the next move, if it is in the bounds of the grid, move the user’s cursor to that position in the grid however if the next move is out of the bounds of the grid, just ignore the users move and read the next move.

The main focus of this program is to use inheritance and pointers. Since we are using inheritance you will want to reuse as much of the code from the provided base class as you can.

You MUST use a pointer in main() with the new operator when you create your game object and you MUST only refer to that object in code using pointer notation.

Starting code:
/You can add or delete includes
#include <iostream>
#include <stdlib.h> //For system()
#include <conio.h> //For getche()
#include <time.h>
using namespace std;

//You can modify these numbers but don't delete these constants or this starting code will not work
const int MAX_HEIGHT = 20; //The height of the grid
const int MAX_WIDTH = 40; //The width of the grid

// DO NOT ALTER OR DELETE THIS CODE (START)!!!!!!!!!!!!!!!!!!!!!!!!!!!
/********************************************************************
* Class: PickUpGame
* Purpose: To store the grid and the current x and y position of the
* user. Also has memeber functions to intialize the grid and print it.
* Allows the user to move around the grid but provides no out of
* bounds checking.
********************************************************************/
class PickUpGame
{
protected:
char Screen[MAX_HEIGHT][MAX_WIDTH]; //The grid to print to the screen
int xPos, yPos; //The current x and y position of the users cursor on the grid

public:
//Constructor that will intialize the screen and x and y positions
PickUpGame() : xPos(0), yPos(MAX_WIDTH - 1)
{
SetupScreen(); //Initalize the grid
}

//Initialize the screen with all '.' characters and set the intial user cursor position on the grid
void SetupScreen()
{
for(int height = 0; height < MAX_HEIGHT; height++) {
for(int width = 0; width < MAX_WIDTH; width++) {
Screen[height][width] = '.'; //Initialize each grid position
}
}
Screen[xPos][yPos] = '<'; //Set the users initial cursor position
}

//Print the grid to the screen
void Print()
{
for(int height = 0; height < MAX_HEIGHT; height++) {
for(int width = 0; width < MAX_WIDTH; width++) {
cout << Screen[height][width]; //Print the character at this location in the grid
}
cout << endl; //After each row is printed, print a newline character
}
}

//Take in user input to move around the grid
void Move(char Direction)
{
switch(static_cast<int>(Direction)) //Don't know the ASCII characters for the arrow keys so use the ASCII numbers
{
case 72: //Up arrow
Screen[xPos][yPos] = ' '; //Wipe out the users current cursor
xPos--; //Move the users x position on the grid
Screen[xPos][yPos] = '^'; //Move the users cursor
break;
case 80: //Down arrow
Screen[xPos][yPos] = ' ';
xPos++;
Screen[xPos][yPos] = 'V';
break;
case 75: //Left arrow
Screen[xPos][yPos] = ' ';
yPos--;
Screen[xPos][yPos] = '<';
break;
case 77: //Right arrow
Screen[xPos][yPos] = ' ';
yPos++;
Screen[xPos][yPos] = '>';
break;
}
}
};
// DO NOT ALTER OR DELETE THIS CODE (END)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

//You can modify and change main()
int main()
{
PickUpGame* Game = new PickUpGame; //Create a new game object and store it in a object pointer

char UserMove = ' '; //This is used to store the users input
do {
system("cls"); //Clear the screen before printing anything
cout << "Welcome to Coin Grab. You will move to the coins by using the arrow keys." << endl; //Program intro
Game->Print(); //Print the grid out
cout << "What direction would you like to move in? \n(Move using the arrow keys or type q to quit.) "; //Instructions to the user
//UserMove = getche(); //Get one character from the user (some compilers have "getche()")
UserMove = _getche(); //Get one character from the user (Visual Studio 2010 "_getche()" is the new version of "getche()")
Game->Move(UserMove); //Process the users input
} while(UserMove != 'Q' && UserMove != 'q'); //Keep running the program until the user types in a Q or q

system("cls"); //Clear the screen
cout << endl;
Game->Print(); //Print the final grid out to the user
cout << endl;

system("PAUSE");
return 0;
}
Please use code tag from right hand side format, before posting code. start with the assignment, post questions if u encounter specific problems, with code snippets.
Topic archived. No new replies allowed.