Singleton – Maze example class MazeFactory { protected MazeFactory() { } private static MazeFactory inst = null ; public static MazeFactory getInst() { if (inst==null) inst = new MazeFactory() ; return inst ; } Maze newMaze() { return new Maze() ; } Room newRoom(int n) { return new Room(n) ; } Wall newWall() { return new Wall() ; } Door newDoor(Room r1, Room r2) { return new Door(r1,r2) ; } }
{}