Package pdp.scrabble.game

Examples of pdp.scrabble.game.Bag


    /**
     * @param args
     */
    public static void main(String[] args) {
  Bag bag = Factory.FACTORY.createBag();
  bag.initWithLanguage("Francais");
  bag.fill();
  Rack r = new RackImplNew(bag);
  r.fill();
  RackView view = new RackView(r);
  RackController ctrl = new RackController(view);
  JFrame frame = new JFrame("test de Rack");
View Full Code Here


    public void tearDown() {
    }

    @Test
    public void bagAccessTester() {
  Bag bag = GAME.bag();

  try {
      bag.initWithLanguage("");
  }
  catch (NullPointerException e) {
      System.out.println("Language doesn't not exist.");
  }

  try {
      bag.initWithLanguage("English");
      System.out.println("Initialize bag");
  }
  catch (NullPointerException e) {
      fail("NullPointerException was not expected");
  }

  try {
      bag.fill();
      System.out.println("Fill bag");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      fail("ArrayIndexOutOfBoundsException was not expected");
  }

  try {
      boolean expResult = false;
      boolean result = bag.isEmpty();
      assertEquals(expResult, result);
      System.out.println("Bag is not empty");
  }
  catch (ArrayIndexOutOfBoundsException e) {
      fail("ArrayIndexOutOfBoundsException was not expected");
  }

  try {
      Letter letter = null;
      bag.addLetter(letter);
      System.out.println("Can add a null letter in bag");
  }
  catch (NullPointerException ex) {
      fail("NullPointerException was not expected");
  }

  try {
      String word = "";
      int expResult = 0;
      int result = bag.getWordValue(word);
      assertEquals(expResult, result);
      System.out.println("getWordValue");
  }
  catch (NullPointerException e) {
      fail("NullPointerException was not expected");
  }

  try {
      String letter = "";
      int expResult = 0;
      int result = bag.getLetterValue(letter);
      assertEquals(expResult, result);
      System.out.println("getLetterValue");
  }
  catch (NullPointerException e) {
      fail("NullPointerException was not expected");
  }

  bag.clear();
  if (bag.getRandomLetter() == null) {
      System.out.println("Can't get a letter from empty bag");
  }
  else {
      fail("null was expected");
  }
View Full Code Here

TOP

Related Classes of pdp.scrabble.game.Bag

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.