-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC4Col.cpp
More file actions
62 lines (54 loc) · 1.17 KB
/
C4Col.cpp
File metadata and controls
62 lines (54 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*Thibault joseph Twahirwa
* CSE 20312, lab1
* implementation of member function
* for class C4Col.h
*/
#include <iostream>
#include <iomanip>
#include "C4Col.h"
using namespace std;
C4Col::C4Col(){
numDiscs = 0; // initialize each column with 0 discs and max capacity discs is 6
maxDiscs = 6;
for ( int i = 0; i <= 5; i++){
Discs[i] = ' '; // set disc value in each column to empty
}
}
C4Col::~C4Col(){
// delete columns content
}
C4Col C4Col::operator+=(char c){
addDisc(c);
return (*this);
}
// int isFull ()
int C4Col::isFull() {
if ( numDiscs >=6){
return 1;
}
else return 0;
}
// int getMaxDiscs()
int C4Col::getMaxDiscs () {
return maxDiscs;
}
// Char getDisc
char C4Col::getDisc(int a) {
if (a >=0&&a <=5){
return Discs[a];
} else {
cout << "Error : out of range selection." << endl;
}
}
// addDisc
void C4Col::addDisc( char newDisc ) {
if ( isFull()){ cout << " this column is full " << endl;
} else {
Discs[numDiscs] = newDisc;
numDiscs++;
}
}
// int C4Col::getNumDisc
int C4Col::getNumDisc() {
return (numDiscs);
}