Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class ConnectFour{
- private:
- char piece1;
- char piece2;
- int turn =0;
- public:
- ConnectFour(char x, char y){
- piece1 = x;
- piece2 = y;
- }
- char board[6][7];
- void display();
- void fillBoard();
- int takeTurn(int location,char piece);
- bool checkWin(int a,int b);
- };
- bool ConnectFour::checkWin(int a,int b){
- int vertical = 1;
- int horizontal = 1;
- int diagonal1 =1;
- int diagonal2 =1;
- char current = board[a][b];
- }
- int ConnectFour::takeTurn(int location,char piece){
- for(int i =5;i>=0;i--)
- {
- if(board[i][location]==' ')
- {
- board[i][location]=piece;
- return i;
- }
- }
- }
- void ConnectFour::fillBoard(){
- for(int i =0;i<=5;i++)
- {
- for(int j =0;j<=6;j++)
- {
- board[i][j] = ' ';
- }
- }
- }
- void ConnectFour::display(){
- cout<<" 1 2 3 4 5 6 7\n";
- for(int a = 0; a<= 5; a++)
- {
- for(int b =0; b <= 6; b++) cout<<char(218)<<char(196)<<char(191)<<" ";
- cout<<'\n';
- for(int b =0; b <= 6; b++) cout<<char(179)<<board[a][b]<<char(179)<<" ";
- cout<<'\n';
- for(int b =0; b <= 6; b++) cout<<char(192)<<char(196)<<char(217)<<" ";
- cout<<'\n';
- }
- }
- int main(int argc, char *argv[])
- {
- int turn = 0;
- char piece1;
- char piece2;
- cout << "Enter player one's game piece (Enter a char)" << endl;
- cin >> piece1;
- cout << "Enter player two's game piece (Enter a char)" << endl;
- cin >> piece2;
- ConnectFour game(piece1,piece2);
- game.fillBoard();
- game.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement