Package logic

Source Code of logic.Game

package logic;

import java.util.ArrayList;

import exceptions.InvalidDiceSetException;
import fileIO.DiceSetReader;
import fileIO.DictReader;
import generator.BoggleField;
import generator.BoggleFieldGenerator;
import gui.Gui;

public class Game
{
  DictReader myDict;
  ArrayList myDiceSet;
  BoggleFieldGenerator myGen;
  Gui myGui;
  BoggleField currentfield;
 
 
  public Game()
  {
    try
    {
      myDict = new DictReader("dict.txt");
      myGen = new BoggleFieldGenerator(DiceSetReader.readDiceSet("nl.txt"));
      myGui = new Gui(this);
      currentfield = myGen.generateField();
      myGui.setField(currentfield);
    }
    catch (InvalidDiceSetException e)
    {
      System.out.println("Invalid Dice set");
    }
   
  }
 
  public void validate(String txt)
  {
    System.out.println(txt + "veld" + currentfield.canContainWord(txt));
    System.out.println(txt + "dict" + myDict.findWord(txt));
    if(!currentfield.canContainWord(txt))
    {
      myGui.setStatus(txt + " cannot be formed !");
      return;
    }
    if(!myDict.findWord(txt))
    {
      myGui.setStatus(txt + " can't be found in the dictionary.");
      return;
    }
    else
    {
      myGui.setStatus(txt + " is correct !");
    }
  }

}
TOP

Related Classes of logic.Game

TOP
Copyright © 2018 www.massapi.com. 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.