Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Board.h"
- using namespace std;
- int main()
- {
- Board b(10);
- b.displayBoard();
- return 0;
- }
- #pragma once
- #include <string>
- #include <iostream>
- using namespace std;
- class Board
- {
- public:
- int width = 10;
- int height = 10;
- char spaces[1000];
- Board(int);
- ~Board();
- const int Area();
- //...//
- void displayBoard(); // <- not being recognized?!
- //...//
- };
- #include "pch.h"
- #include "Board.h"
- #include <iostream>
- using namespace std;
- Board::Board(int s)
- {
- width = height = s;
- //assumes spaces holds at least width*height
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- if (static_cast<bool>((i + j) % 2)) {
- spaces[i*width + j] = ' ';
- }
- else {
- spaces[i*width + j] = '#';
- }
- }
- }
- }
- Board::~Board()
- {
- //delete spaces;
- }
- const int Board::Area()
- {
- return width * height;
- }
- //...//
- void Board::displayBoard(void)
- {
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- cout << spaces[i*width + j];
- }
- cout << endl;
- }
- return void();
- }
- //...//
Add Comment
Please, Sign In to add comment