1. Making a Game Assignment

The assignment is to create three different raceways and populate them with obstacles, N = waves in Seaway, M = oil in Raceway, and O = fog in Airway. Three different vehicles on three different raceways, a boat, a car, and a plane are racing each others. They move at different speeds and the obstacles slow move them back by different amounts. The exact instructions are posted here: CS320 Programming Languages: Program Three

We've managed to create the three raceways and populate them with the obstacles at random. The question is how do we access the Raceway class in our Vehicle class to let the sub-classes know there is an obstacle that it's about to hit and therefor will be moved back by a certain amount of units.

Code:
```//Great Vehicle Race
//Written by Douglas Oonk & Jack Trocinski

#include <iostream>
#include <cstdlib>

using namespace std;

class Raceway {
public:
char seaway[3][100];
char airway[3][100];
void race() {

srand(time(0));

for(int i=0; i < 3; i++){
for(int j = 0; j < 100; j++){
seaway[i][j] = '-';
airway[i][j] = '-';
}
}
for(int i=0; i < 3; i++){
for(int n = 0; n< 4; n++) {
int j = rand()%100;
}
}
for(int i=0; i < 3; i++){
for(int n = 0; n< 4; n++) {
int j = rand()%100;
seaway[i][j] = 'N';	//large waves
}
}
for(int i=0; i < 3; i++){
for(int n = 0; n< 4; n++) {
int j = rand()%100;
airway[i][j] = 'O';	//fog
}
}
}

////////////////////////////////////////////print arrays//////////////////////////////////////

void printSeaway() {
cout << "The Seaway race" << endl;
for(int i=0; i < 3; i++){
for(int j = 0; j < 100; j++){
cout << seaway[i][j];
}
cout << endl;
}
}

cout << "The Roadway race" <<endl;
for(int i=0; i < 3; i++){
for(int j = 0; j < 100; j++){
}
cout << endl;
}
}

void printAirway() {
cout << "The Airway race" << endl;
for(int i=0; i < 3; i++){
for(int j = 0; j < 100; j++){
cout << airway[i][j];
}
cout << endl;
}
}

};

//end class race

class Vehicle {
public:
virtual int move() = 0;
};

class Wheeled: public Vehicle {
public:
int move() {
return 3;
}
};

class Propellored: public Vehicle {
public:
int move() {
return 4;
}
};

class FourWD: public Wheeled {
public:
int move() {
return 2;		//if hits oil spills
}
};

class Cycle: public Wheeled {
public:
int move() {
return 0;		//if hits oil spills
}
};

class Boat: public Propellored {
public:

int move() {
return 2;		//if hits large waves
}
};

class Plane: public Propellored {
public:
int move() {
return 2;		//if hits fog
}
};

int main() {
cout << "Welcome to the  Great Raceway!" << endl;
cout << "Written by Doug Oonk and Jack Trocinski" << endl;

Raceway raceObject;
raceObject.race();

raceObject.printSeaway();
raceObject.printAirway();

return 0;
}```

2. This is an ugly, overly-contrived assignment. However...

Your question is how do the vehicles access the raceways. Note that the interfaces for the member functions are completely unspecified. So, for instance, the move function could take a raceway reference.

Other points:

You're not following these directions:
* The values of N, M and O should be between 10 and 50.
* At least two blank columns should follow any column with an obstacle.

Note that it is not actually telling you to put the characters N, M, and O onto the raceways. You could presumably use asterisks, since each raceway type has it's own unique obstacle type. N, M, and O are variables that you randomly set between 10 and 50.

Your Vehicle class has no member variables, and yet the assignment says it should "know the index of the cell it is in in its raceway track and it should have a direction."

I'm not sure what this sentence (for lack of a better word) in the assignment means: "Create a loop that iterates of each over four instances of the object types and moves them according to these rules." Presumably it means one instance of the 4 vehicle types.

3. Originally Posted by oogabooga
This is an ugly, overly-contrived assignment. However...
I agree, and thanks for the help