Advertisement
Guest User

Untitled

a guest
Mar 26th, 2010
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. public class Connect4Column
  2. {
  3.     private int counters[];
  4.     private int numCounters;
  5.     private int MAX_NUM_COUNTERS;
  6.  
  7.     static int YELLOW_COUNTER = 1;
  8.     static int RED_COUNTER = 2;
  9.  
  10.     public Connect4Column(int max_counters)
  11.     {
  12.         MAX_NUM_COUNTERS = max_counters;
  13.         counters = new int[MAX_NUM_COUNTERS];
  14.         numCounters = 0;
  15.     }
  16.  
  17.     public boolean addCounter(int thisCounter)
  18.     {
  19.         if ((numCounters < MAX_NUM_COUNTERS)&&((thisCounter == 1)||(thisCounter == 2)))
  20.         {
  21.             counters[numCounters] = thisCounter;
  22.             numCounters++;
  23.             return true;
  24.         }
  25.         else
  26.         {
  27.             return false;
  28.         }
  29.     }
  30.  
  31.     public int getNumCounters()
  32.     {
  33.         return numCounters;
  34.     }
  35.  
  36.     public int getCounter(int thisRow)
  37.     {
  38.         if ((thisRow >= 0)&&(thisRow <= numCounters))
  39.         {
  40.             return counters[thisRow];
  41.         }
  42.         else
  43.         {
  44.             return 0;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement