Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7.  
  8.  
  9. class ConnectFour{
  10. private:
  11. char piece1;
  12. char piece2;
  13. int turn =0;
  14. public:
  15.  
  16. ConnectFour(char x, char y){
  17. piece1 = x;
  18. piece2 = y;
  19.  
  20.  
  21. }
  22. char board[6][7];
  23. void display();
  24. void fillBoard();
  25. int takeTurn(int location,char piece);
  26. bool checkWin(int a,int b);
  27.  
  28.  
  29. };
  30.  
  31. bool ConnectFour::checkWin(int a,int b){
  32. int vertical = 1;
  33. int horizontal = 1;
  34. int diagonal1 =1;
  35. int diagonal2 =1;
  36. char current = board[a][b];
  37.  
  38.  
  39. }
  40.  
  41. int ConnectFour::takeTurn(int location,char piece){
  42. for(int i =5;i>=0;i--)
  43. {
  44. if(board[i][location]==' ')
  45. {
  46. board[i][location]=piece;
  47. return i;
  48. }
  49. }
  50. }
  51.  
  52. void ConnectFour::fillBoard(){
  53. for(int i =0;i<=5;i++)
  54. {
  55. for(int j =0;j<=6;j++)
  56. {
  57. board[i][j] = ' ';
  58. }
  59. }
  60. }
  61.  
  62. void ConnectFour::display(){
  63.  
  64. cout<<" 1 2 3 4 5 6 7\n";
  65.  
  66. for(int a = 0; a<= 5; a++)
  67. {
  68. for(int b =0; b <= 6; b++) cout<<char(218)<<char(196)<<char(191)<<" ";
  69. cout<<'\n';
  70. for(int b =0; b <= 6; b++) cout<<char(179)<<board[a][b]<<char(179)<<" ";
  71. cout<<'\n';
  72. for(int b =0; b <= 6; b++) cout<<char(192)<<char(196)<<char(217)<<" ";
  73. cout<<'\n';
  74. }
  75. }
  76.  
  77. int main(int argc, char *argv[])
  78. {
  79. int turn = 0;
  80. char piece1;
  81. char piece2;
  82. cout << "Enter player one's game piece (Enter a char)" << endl;
  83. cin >> piece1;
  84. cout << "Enter player two's game piece (Enter a char)" << endl;
  85. cin >> piece2;
  86.  
  87. ConnectFour game(piece1,piece2);
  88. game.fillBoard();
  89. game.display();
  90.  
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement