// file: PlainFinder.h
// by: Dawn Lawrie
// date: February 17, 2005


#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;
#ifndef PLAIN_FINDER_H
#define PLAIN_FINDER_H


struct Plain {
  int x;
  int y;
  int max;
};

class PlainFinder {
 private:
  int size;          // number of rows/columns in the map
  int **theMap;      // elevations of the regions
  bool **visit;      // keeps track of visits to region
                     // when finding largest plain

  // Sets all the elements in visit to false
  void initVisit();  

  // Recursively finds size of plain
  // @param value - elevation of current plain
  // @param rPos - row of the region
  // @param cPos - column of the region
  // @return - size of plain explored from this position
  int calcPlain(int value, int rPos, int cPos);  

 public:
  // Constructor
  // @ param s - size of the map
  PlainFinder(int s);

  // Destructor
  ~PlainFinder();

  // Reads a file and puts the values in an array
  // preconditions: map has been allocted and the file
  //         holds data for the size map
  // postcondtion: If read sucessful, true is returned and map has data
  //      from the file.
  //      Otherwise, false is return and the map is invalid
  // @param - name of file containing elevation data
  // @return - true if read sucessful
  bool initMap(string filename);  

  // Prints map in the terminal window
  // precondition: map contains data
  // postcondition: the map data is displayed to standard out
  void displayMap();  
  
  // Finds the largest plain and returns information
  // precondition: map contains data
  // postcondition: return value holds the number of regions in the 
  //        largest plain and the corredinates of one of the regions
  // @return - size and location of the largest plain
  Plain findLargestPlain();  
};

#endif

