package questions; import javax.swing.JOptionPane; public class Game { public static void main(String[] args) { AnimalVegetableMineralQuestion root = new AnimalVegetableMineralQuestion(new Animal("cardinal"), new Vegetable("maple tree"), new Mineral("iron")); int keepPlaying = JOptionPane.YES_OPTION; final String TITLE = "20 Questions"; String[] categories = {"Animal", "Vegetable", "Mineral"}; do { int response = //TODO: Create first JOptionPane Block current = null; if(response == 0) current = root.getAnimal(); else if(response == 1) current = root.getVegetable(); else current = root.getMineral(); Block parent = root; while(current instanceof YesOrNoQuestion) { parent = current; response = //TODO: Create second JOptionPane YesOrNoQuestion question = (YesOrNoQuestion) current; if(response == JOptionPane.YES_OPTION) current = question.getYesAnswer(); else current = question.getNoAnswer(); } String kind; if(current instanceof Animal) kind = "animal"; else if(current instanceof Vegetable) kind = "vegetable"; else kind = "mineral"; response = //TODO: Create third JOptionPane if(response == JOptionPane.YES_OPTION) { //TODO: Create fourth JOptionPane } else { String name = //TODO: Create fifth JOptionPane String questionText = //TODO: Create sixth JOptionPane YesOrNoQuestion question; if(current instanceof Animal) question = new YesOrNoQuestion(questionText, new Animal(name), current); else if(current instanceof Vegetable) question = new YesOrNoQuestion(questionText, new Vegetable(name), current); else question = new YesOrNoQuestion(questionText, new Mineral(name), current); if(parent == root) { if(current instanceof Animal) root.setAnimal(question); else if(current instanceof Vegetable) root.setVegetable(question); else root.setMineral(question); } else { YesOrNoQuestion parentQuestion = (YesOrNoQuestion) parent; if(current == parentQuestion.getYesAnswer()) parentQuestion.setYesAnswer(question); else parentQuestion.setNoAnswer(question); } } keepPlaying = //TODO: Create seventh JOptionPane } while(keepPlaying == JOptionPane.YES_OPTION); } }