import java.awt.*;
public class Quiz extends EasyApp
{
public static void main(String[] args)
{ new Quiz(); }
Button bScience = addButton("Science",50,50,100,50,this);
Button bSports = addButton("Sports",150,50,100,50,this);
Button bHistory = addButton("History",250,50,100,50,this);
public Quiz() // Constructor - change window appearance
{
setSize(400,150);
}
public void actions(Object source,String command)
{
if (source == bScience)
{ science(); }
if (source == bSports)
{ sports(); }
if (source == bHistory)
{ history(); }
}
public void science()
{
String guess = inputString("f = ma is a ________ law");
if (guess.equals("physics"))
{ output("Right!"); }
else
{ output("Wrong..."); }
}
public void sports()
{
String guess = inputString("What sport did Pele play?");
if (guess.equals("soccer"))
{ output("Right!"); }
else
{ output("Wrong..."); }
}
public void history()
{
int guess = inputInt("What year did WW II end?");
if (guess == 1945)
{ output("Right!"); }
else
{ output("Wrong..."); }
}
}
/******************************************************************
(1) Copy the program, compile and test it - you will need EasyApp.
(2) Add a new button to ask a question you find interesting.
(3) Make suggestions for improvements, and let the TEACHER
show you how to make the appropriate changes.
Be sure to take NOTES while the teacher is talking -
you can write them on this page.
*******************************************************************/