Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Connect4Column
- {
- private int counters[];
- private int numCounters;
- private int MAX_NUM_COUNTERS;
- static int YELLOW_COUNTER = 1;
- static int RED_COUNTER = 2;
- public Connect4Column(int max_counters)
- {
- MAX_NUM_COUNTERS = max_counters;
- counters = new int[MAX_NUM_COUNTERS];
- numCounters = 0;
- }
- public boolean addCounter(int thisCounter)
- {
- if ((numCounters < MAX_NUM_COUNTERS)&&((thisCounter == 1)||(thisCounter == 2)))
- {
- counters[numCounters] = thisCounter;
- numCounters++;
- return true;
- }
- else
- {
- return false;
- }
- }
- public int getNumCounters()
- {
- return numCounters;
- }
- public int getCounter(int thisRow)
- {
- if ((thisRow >= 0)&&(thisRow <= numCounters))
- {
- return counters[thisRow];
- }
- else
- {
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement