/* Scrabble : An interactive scrabble playing software. Copyright (C) 1999 Amitabh Sinha All Trademarks and Copyrights pertaining to Scrabble, Java, Linux acknowledged. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact Amitabh at */ import java.io.*; import java.util.*; public class Cell { String type; int xPos; int yPos; Cell north, south, west, east; Letter letter; boolean occupied; public Cell (String s, int x, int y) { type = new String(s); xPos = x; yPos = y; letter = null; occupied = false; north = null; south = null; west = null; east = null; } public void setNeighbour(String s, Cell c) { if (s.equals("North")) north = c; else if (s.equals("South")) south = c; else if (s.equals("East")) east = c; else if (s.equals("West")) west = c; else System.out.println("Undefined Cell direction"); } public void setType (String s) { type = s; } public int getWordFactor() { if (type.equals("Triple Word")) return 3; else if (type.equals("Double Word") || type.equals("Start")) return 2; else return 1; } public int getLetterFactor() { if (type.equals("Double Letter")) return 2; else if (type.equals("Triple Letter")) return 3; else return 1; } public boolean isOccupied() { return occupied; } public Letter getLetter() { return letter; } public int getX() { return xPos; } public int getY() { return yPos; } public boolean setLetter(Letter l) { if (occupied) return false; occupied = true; letter = l; return true; } public Cell getNeighbour (String s) { if (s.equals("North")) return north; else if (s.equals("South")) return south; else if (s.equals("East")) return east; else if (s.equals("West")) return west; return null; } public Cell getNeighbourInt (int i, char c) { if (c=='x') { if (i==1) return north; else if (i==3) return south; else if (i==4) return east; else if (i==2) return west; } else if (c=='y') { if (i==1) return west; else if (i==3) return east; else if (i==4) return south; else if (i==2) return north; } return null; } public String getType () { return type; } public void removeLetter() { letter = null; occupied = false; } }