Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *****MAIN*****
- #include "TextFill.h"
- int main()
- {
- char choice, symbol;
- string file;
- int row, column;
- Recursion textFill;
- bool keepGoing = true;
- // How can I make sure user chooses L before F or S?
- // cout << "Select from the options: (L)oad art, (F)ill, (S)ave art " << endl;
- // cout << "Choice? ";
- // cin >> choice;
- // if (choice == 'F' || choice == 'S')
- // {
- // cout << "You must load the file before filling it or saving it" << endl;
- // }
- // cout << endl;
- while (keepGoing)
- {
- cout << "Select from the options: (L)oad art, (F)ill, (S)ave art " << endl;
- cout << "Choice? ";
- cin >> choice;
- if (choice == 'L')
- {
- //load text file
- cout << "File to read: ";
- cin >> file;
- //textFill.load(file);
- }
- else if (choice == 'F')
- {
- //fill function
- cout << "Cell to begin Fill: " << endl;
- cout << "Cell Row: ";
- cin >> row;
- cout << "Cell Column: ";
- cin >> column;
- cout << "Symbol: ";
- cin >> symbol;
- //textFill.fill(row, column, symbol);
- }
- else if (choice == 'S')
- {
- //save file function
- cout << "File to write: ";
- cin >> file;
- keepGoing = false;
- //textFill.save(file);
- }
- else
- {
- cout << "Please choice a valid option " << endl;
- }
- }
- return 0;
- }
- *****class*****
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- class Recursion
- {
- private:
- int column;
- int row;
- char ** grid;
- char symbol;
- fstream file;
- public:
- Recursion()
- {
- column = -1; //this is wrong
- row = -1; //this is also wrong
- grid = new char*[size of art row];
- for(int i = 0; i < size of art; i++)
- {
- grid[row] = new char[size of art column]
- }
- }
- //if
- void fill(int row, int column, char symbol)
- {
- //base case
- if(grid[row][column] != ' ') //if the location already has a character, do nothing
- {
- // do nothing
- }
- else
- {
- //fill the locaton recursively.
- //in order to fill it recursively, you must
- fill(row - 1, column, symbol); //fill location above orginal location
- fill(row + 1, column, symbol); //fill location below original locaiton
- fill(row, column - 1, symbol); //fill location to the left of the original location
- fill(row, column + 1, symbol); //fill location to the right of the original locaiton
- }
- }
- void load(string filename)
- {
- }
- void save(string file)
- {
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement