Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GameOfLife::seedBoard(string fileName) throw(csci2312::FileIOException)
- {
- // Open input file
- ifstream inFile;
- inFile.open("cells.txt");
- int value;
- if(!inFile)
- {
- cout << "Error opening the file!" << endl;
- }
- while(!inFile.eof())
- {
- // Loop through each row
- for(int row = 0; row < boardSize / boardSize; row++)
- {
- // Loop through each column
- for(int col = 0; col < boardSize; col++) //why does this work, but not "int col = 0"?
- {
- // Get a value from the file [alternatively you can place this at the top of your loop]
- inFile >> value;
- // Set value of currentLife
- if (value == 0)
- {
- currentLife[row][col].setState(false);
- }
- else if(value == 1)
- {
- currentLife[row][col].setState(true);
- }
- // Output row/column value
- cout << value;
- }
- // End line after all cells in the row are displayed
- cout << '\n';
- }
- }
- inFile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement