package fun;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;

import java.util.*;

public class T3MIDlet extends MIDlet {

	public void startApp(){
		Vector ids = T3Library.getIDs();
		getDisplay().setCurrent(new T3Choice(this, ids));
	}

	public void pauseApp(){}
	public void destroyApp(boolean unconditional){}
	
	public void initPuzzle(int id){
		T3Puzzle p = T3Library.load(id);
		if(p == null){
			p = new T3Puzzle();
		}
		getDisplay().setCurrent(new T3Board(this, p));
	}
	
	public void exitPuzzle(T3Puzzle p){
		T3Library.save(p);
		notifyDestroyed();
	}
	
	private Display getDisplay(){
		return Display.getDisplay(this);
	}
}