This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 26th, 2010  |  syntax: Java  |  size: 0.80 KB  |  views: 172  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data