model
Class TuringBattle

java.lang.Object
  extended by model.TuringBattle

public class TuringBattle
extends java.lang.Object

The controller class. Provides a single point of management for the TuringBattle system.

Author:
nadim

Constructor Summary
TuringBattle(java.lang.String mappath)
          Takes the filename of a map as input
TuringBattle(TuringMap map)
          Takes the default map as an input
 
Method Summary
 boolean addState(TuringState state)
          Adds the state to the state manager If something goes wrong, return false
 void executeNextInstruction()
          Attempts to execute the next instruction
 int[] getMap()
          Get's the current map
 int getNumberOfColumns()
           
 int getNumberOfRows()
           
 void loadStates()
          Loads the states file
 void saveStates()
          Save out the states to a file
 void setMap(java.lang.String filename)
          Attempts to change the map If cannot do so, the current map isn't affected and an exception is thrown
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TuringBattle

public TuringBattle(TuringMap map)
             throws java.lang.Exception
Takes the default map as an input

Parameters:
map -
Throws:
java.lang.Exception

TuringBattle

public TuringBattle(java.lang.String mappath)
             throws java.lang.Exception
Takes the filename of a map as input

Parameters:
map -
Throws:
java.lang.Exception
Method Detail

setMap

public void setMap(java.lang.String filename)
            throws java.lang.Exception
Attempts to change the map If cannot do so, the current map isn't affected and an exception is thrown

Parameters:
map -
Throws:
ExceptionTuring
java.lang.Exception

addState

public boolean addState(TuringState state)
Adds the state to the state manager If something goes wrong, return false

Returns:
true if successful

executeNextInstruction

public void executeNextInstruction()
                            throws java.lang.Exception
Attempts to execute the next instruction

Throws:
java.lang.Exception

getMap

public int[] getMap()
Get's the current map

Returns:
the current map

getNumberOfRows

public int getNumberOfRows()
Returns:
the number of rows in the map

getNumberOfColumns

public int getNumberOfColumns()
Returns:
the number of columns in the map

loadStates

public void loadStates()
                throws java.lang.Exception
Loads the states file

Throws:
java.lang.Exception

saveStates

public void saveStates()
Save out the states to a file