/*
 * @topic T11384 Exception demo VIII
 * @brief class MazeGame is a singleton class
*/

package week08exceptions;

public class MazeGame {
    static private MazeGame maze = null;
    
    
    private MazeGame()
    {
    }
    
    // object factory method
    public static MazeGame createMaze( int configID ) throws Exception
    {
        if ( maze == null ) {
            try {
                maze = buildMaze( configID );
            } catch ( Exception ex ) {
                // do some additional processing
                throw ex;
            }
        }
        return maze;
    }
    
    public static MazeGame buildMaze( int configID ) throws Exception
    {
        if ( configID == -1 ) {
            throw new ExBadConfiguration( "Missing maze configuration" );
        } else if ( configID == -2 ) {
            throw new ExBadUserPrivilege( "Insufficient user privilege" );
        }
        return new MazeGame();
    }
    
    public void print()
    {
    }
}//class MazeGame