CS360 Assignment 4

Online Quiz

 

Date Assigned: Tuesday, March 16, 2004

Date Due: Tuesday, March 30, 2004

Total Points: 60

Introduction

For this assignment you are to write a Java applet for an online quiz. The applet should contain multiple panels, (1) the current date and time, (2) the questions, (3) the answer box and submit button and (4) the total duration in minutes.

Goals

This assignment will give you practical experience in:

-       Multithreaded programs

-       Reading from files

-       Modular programming. Each panel will be in its own module that you can plug in whenever you need it.

Assignment

The best way to tackle this assignment is to break it up into different parts. You can complete each part individually and plug it into the applet.

Current Date and Time

The applet should contain todayÕs date and the current time of day. The time should include the hours, minutes and seconds and needs to be updated every second. This clock should run as a separate thread since it needs to continually update, while the user should still have the ability to play the quiz.

 

The clock should be placed in itÕs own panel that can be added to any interface. You will need two classes to implement this panel.

-       Class ClockPanel that extends Jpanel. This class will get the system date and time and place it onto the panel. To get the date and time you should use:
private Date date = new Date();
timeString =
   java.text.DateFormat.getDateTimeInstance().format(date);
This class should also contain the method draw that will get called in the appletÕs repaint method.

-       Class Clock that extends Thread. This method will call the appletÕs repaint method every second to update the clock.

Once youÕve completed this step move onto the quiz panel.

Quiz

For the quiz part of this assignment, you will need to read the questions and answers from a file. The file will be placed in the same directory as your java and html files. The format of the file will be a question one line followed by the answer on the next line followed by the next question etc. You can have as many questions as you like.

 

The quiz panel should contain a text field and button where the user can enter the time limit for this quiz. The total time limit should be between 1 and 10 minutes. The user can select their time limit at the start of the quiz, then the text field and button will be greyed out so they canÕt change their time. The timer should count down as a separate thread.

 

The quiz panel should also contain a text field or label to display the question, a text field for the user to enter the answer and a submit button to submit their solution.

 

You can create as many classes as you like or need. However, you must have one class called QuizPanel that you can then add to the Java applet or any GUI Java program.

Optional Password Field

For extra credit, only allow specific users to play the quiz. Use the password field class that you created for the last assignment to check if a user is allowed to take the quiz.

Error Checking

Perform as much error checking as you can. You will be graded on this. If possible use exception handling.

Submitting your programs:

Save all your files in a folder called (your PUNET ID) and place the folder in the CS360 drop folder by 9.25 AM on the assignment due date. You do not need to submit the .class files. Just submit your .java files.