Package pdp.scrabble.game

Examples of pdp.scrabble.game.Board


    public void tearDown() {
    }

    @Test
    public void boardAccessTester() {
  Board board = GAME.board();

  try {
      board.getCase(0, 0);
      System.out.println("Can get 0, 0");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      fail("ArrayIndexOutOfBoundsException was not expected");
  }

  try {
      board.getCase(-1, -1);
      System.out.println("Can get -1, -1; but not recommended (safe border only)");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      fail("ArrayIndexOutOfBoundsException was not expected");
  }

  try {
      board.getCase(-2, -2);
      fail("ArrayIndexOutOfBoundsException was expected");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      System.out.println("Can't get -2, -2");
  }

  System.out.println("Clear board and validate it");
  board.clear();
  try {
      board.validate(true);
      System.out.println("Board check ignored, because no new letter added");
  }
  catch (BoardWrongWordPlace ex) {
      fail("BoardWrongWordPlace was not expected");
  }

  System.out.println("Add new letter at 0, 0");
  board.setCaseLetter(0, 0, FACTORY.createLetter('A', 1, 0), true);
  try {
      board.validate(true);
      fail("BoardWrongWordPlace was expected");
  }
  catch (BoardWrongWordPlace ex) {
      System.out.println("BoardWrongWordPlace error, because center is not used");
  }

  try {
      board.cancel(null);
  }
  catch (NullPointerException ex) {
      fail("NullPointerException was not expected");
  }

  try {
      board.switchCasesLetter(-1, -1, 0, 0);
      System.out.println("Can switch -1, -1 and 0, 0, but not recommended (used as safe area)");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      fail("ArrayIndexOutOfBoundsException was not expected");
  }

  try {
      board.switchCasesLetter(-2, -2, 0, 0);
      fail("ArrayIndexOutOfBoundsException was expected");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      System.out.println("Can't switch -2, -2 and 0, 0");
  }
View Full Code Here


  this.isAutoSave = autoSave;
    }


    public Board clone() {
  Board board = FACTORY.createBoard();
  board.setDictionary(this.dictionary);
  board.setData(this.centerUsed, this.points, this.length, this.words);

  for (int v = 0; v < VERT_DIM; v++) {
      for (int h = 0; h < HORI_DIM; h++) {
    BoardCase boardCase = this.getCase(v, h).clone();
    board.setCase(v, h, boardCase);
      }
  }

  return board;
    }
View Full Code Here

  return board;
    }


    public Board transpose() {
  Board trans = Factory.FACTORY.createBoard();
  for (int v=0; v < VERT_DIM ; v++)
      for (int h=0; h < HORI_DIM; h++)
    trans.setCase(h, VERT_DIM-v, this.getCase(v, h).clone());
  return trans;
    }
View Full Code Here

TOP

Related Classes of pdp.scrabble.game.Board

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.