PierreK 0 Newbie Poster

Hello all, Im working on my assignment that deals w/ the use of classes but I'm a bit stuck at the moment.
The assignment overview is fairly simple: I just need to read in a .dat file which contains some elevation data into a 2d array and then use that to make an UAV fly through the elevation and pick out craters.
I have completed 2 out of the three classes instructor has gave us to complete, but I am totally lost for the 3rd class. I can finish the other member functions, but when it comes to defining the bool functions I just don't know how to do it. The main goal of the bool functions is to determine if the UAV can move left,right,down,up respectively. If UAV can move left, then move left, and so on. But how do I begin traversing? I do understand I will need a nested for loop since it's a 2d array.

I have a fair idea of what to do, but any insights you all can give me will be very much appreciated.

this is the header for the final class,

#define MAXSIZE 100

class RPV
{
private:
	Position position;
	Position CratersFound[MAXSIZE];
	int TotalCraters;
	void MarkCraterPosition();
	bool PositionIsCrater(Terrain *terrain);
public:
	RPV();
	bool moveLeft(Terrain *terrain);
	bool moveRight(Terrain *terrain);
	bool moveUp(Terrain *terrain);
	bool moveDown(Terrain *terrain);
	int GetPositionX();
	int GetPositionY();
	void PrintCraterPositions();
	void Navigate(Terrain *terrain);
};

Please don't mind the other member functions as I am only concerned w/ the bool functions. Also the position class I have not included in this post since, it's only made up of a few return statements that just give values. I do understand that I will need a terrain pointer, just how do I go about doing this? Any sort of info would be helpful.

I have the entire terrain class here...

#include <iostream>
#include <fstream>
#include "Terrain.h"
using namespace std; 


Terrain::Terrain()
{
	rowsize = 0; 
	columnsize = 0;
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < N; j++)
		{
			gridmap[i][j] = 0; 
		}
	}
}


Terrain::Terrain(int m, int n)
{
	rowsize = m; 
	columnsize = n; 
}

void Terrain::LoadMap(ifstream &in)
{

		cout << "Loading terrain information...\n\n"; 
		for(int i = 0; i < rowsize; i++)
		{
			for(int j = 0; j < columnsize; j++)
			{
				in >> gridmap[i][j]; 
			}
		}
}


void Terrain::PrintMap()
{ 	

	cout << "Printing terrain information...\n\n"; 
	for(int r = 0; r < rowsize; r++)
	{
		for(int c = 0; c < columnsize; c++)
		{
			cout << gridmap[r][c] << "\t"; 
		}
		cout << endl; 
	}
}

int Terrain::GetRowSize()
{
	return rowsize; 
}

int Terrain::GetColumnSize()
{
	return columnsize; 
}

//function for GetElevation

int Terrain::GetElevation(int i, int j)
{
	return gridmap[i][j]; //i represents row number, and j represents column number
}

Please and thank you all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.