Advertisement
Guest User

Untitled

a guest
Mar 26th, 2018
847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.99 KB | None | 0 0
  1. *****MAIN*****
  2. #include "TextFill.h"
  3. int main()
  4. {
  5.     char choice, symbol;
  6.     string file;
  7.     int row, column;
  8.     Recursion textFill;
  9.     bool keepGoing = true;
  10. //      How can I make sure user chooses L before F or S?
  11. //    cout << "Select from the options: (L)oad art, (F)ill, (S)ave art " << endl;
  12. //    cout << "Choice? ";
  13. //    cin >> choice;
  14. //    if (choice == 'F' || choice == 'S')
  15. //    {
  16. //        cout << "You must load the file before filling it or saving it" << endl;
  17. //    }
  18. //    cout << endl;
  19.    
  20.     while (keepGoing)
  21.     {
  22.         cout << "Select from the options: (L)oad art, (F)ill, (S)ave art " << endl;
  23.         cout << "Choice? ";
  24.         cin >> choice;
  25.        
  26.         if (choice == 'L')
  27.         {
  28.             //load text file
  29.             cout << "File to read: ";
  30.             cin >> file;
  31.             //textFill.load(file);
  32.         }
  33.         else if (choice == 'F')
  34.         {
  35.             //fill function
  36.             cout << "Cell to begin Fill: " << endl;
  37.             cout << "Cell Row: ";
  38.             cin >> row;
  39.             cout << "Cell Column: ";
  40.             cin >> column;
  41.             cout << "Symbol: ";
  42.             cin >> symbol;
  43.            
  44.             //textFill.fill(row, column, symbol);
  45.         }
  46.         else if (choice == 'S')
  47.         {
  48.             //save file function
  49.             cout << "File to write: ";
  50.             cin >> file;
  51.             keepGoing = false;
  52.             //textFill.save(file);
  53.         }
  54.         else
  55.         {
  56.             cout << "Please choice a valid option " << endl;
  57.         }
  58.     }
  59.    
  60.    
  61.     return 0;
  62. }
  63.  
  64. *****class*****
  65. #include <iostream>
  66. #include <string>
  67. #include <fstream>
  68. using namespace std;
  69.  
  70. class Recursion
  71. {
  72. private:
  73.     int column;
  74.     int row;
  75.     char ** grid;
  76.     char symbol;
  77.     fstream file;
  78.    
  79. public:
  80.     Recursion()
  81.     {
  82.         column = -1; //this is wrong
  83.         row = -1; //this is also wrong
  84.         grid = new char*[size of art row];
  85.         for(int i = 0; i < size of art; i++)
  86.         {
  87.             grid[row] = new char[size of art column]
  88.         }
  89.        
  90.        
  91.     }
  92.     //if
  93.     void fill(int row, int column, char symbol)
  94.     {
  95.         //base case
  96.         if(grid[row][column] != ' ') //if the location already has a character, do nothing
  97.         {
  98.             // do nothing
  99.         }
  100.         else
  101.         {
  102.             //fill the locaton recursively.
  103.             //in order to fill it recursively, you must
  104.             fill(row - 1, column, symbol); //fill location above orginal location
  105.             fill(row + 1, column, symbol); //fill location below original locaiton
  106.             fill(row, column - 1, symbol); //fill location to the left of the original location
  107.             fill(row, column + 1, symbol); //fill location to the right of the original locaiton
  108.         }
  109.     }
  110.    
  111.    
  112.    
  113.     void load(string filename)
  114.     {
  115.  
  116.     }
  117.    
  118.     void save(string file)
  119.     {
  120.        
  121.     }
  122.    
  123.    
  124.    
  125. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement