1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/**
* @file Wordpuzzle.h
* The file for the class Wordpuzzle
* @author Him Cheng
*/
#ifndef _WORDPUZZLE_H_
#define _WORDPUZZLE_H_
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
/**
* A class for storing the wordpuzzle and providing basic operations to the puzzle
*/
class Wordpuzzle
{
public:
/**
* Default constructor, the puzzle is set to empty state
*/
Wordpuzzle();
/**
* Construct a new row x col rectangular puzzle, all filled in the specified character
* @param row Number of row in the puzzle
* @param col Number of col in the puzzle
* @param c A default letter to fill into the puzzle
*/
Wordpuzzle(int row, int col, char c);
/**
* Construct a new rectangular puzzle by reading a file
* @param filename Filename of the file storing the puzzle
*/
Wordpuzzle(const char* filename);
/**
* Copy constructor
* @param wp another instant of Wordpuzzle to copy from
*/
//Wordpuzzle(const Wordpuzzle &wp);
/**
* Destructor
*/
//~Wordpuzzle();
/**
* Get the character in [row,col] of the puzzle
* @param row The row index, starting from 0
* @param col the column index, starting from 0
* @return The character stored in the [row,col] of the puzzle
*/
//char getCharacter(int row, int col) const;
/**
* Set the character in [row,col] of the puzzle
* @param row The row index, starting from 0
* @param col The column index, starting from 0
* @param c The new letter to be set
* @return Return true if set successfully, otherwise, return false
*/
//bool setCharacter(int row, int col, char c);
/**
* Set the word puzzle instant to a new puzzle by reading a puzzle file
* @param filename The filename of the file which store the new puzzle
* @return Return true if set successfully, otherwise, return false
*/
//bool setPuzzle(const char* filename);
/**
* Count the number of existance of the word in the puzzle
* @param word The target word to be counted
* @return The number of existance
*/
//int countWord(const std::string &word) const;
/**
* Resize the puzzle
* @param row The new number of row in the puzzle
* @param col The new number of col in the puzzle
* @param c The character used to fill in the enlarged part
* @return Return true if resize successfully, otherwise, return false
*/
//bool resize(int row, int col, char c = '*');
/**
* Clear the puzzle into empty state
*/
//void clear();
/**
* Print out the puzzle
*/
void print() const;
private:
/* ====================================
Add your own function here if needed
===================================*/
char **_data; ///2-D dynamic array to store the puzzle
int _numOfRow; ///Number of row in the puzzle
int _numOfCol; ///Number of column in the puzzle
};
#endif //_WORDPUZZLE_H_
|