CS364 Spring 2008 Take Home Final Exam/Project
This is the CS364 Spring 2008 final exam. The work for this project must
be entirely your own work. You should not speak to, chat, consult, e-mail,
or communicate in any way with anyone about this program other than the instructor.
This final exam counts 20% towards your final grade (see syllabus). You may
use external reference material such as your textbook, a Java book, or the
Sun Java API web pages but all of the program code must be your own, developed
and written solely by you. You may not use any code in your project that you
did not develop yourself. If this is not clear please see see me.
This project is due by 4:30PM on Saturday May 10,
the scheduled end of the final exam period for this class.
The project should be in your student folder and be in a folder
named FinalExam
.
Turn in a stapled printout of your final project in my mailbox or under my door by the due date and time.
Program Functional Requirements
In this program you are going to build a Swing GUI application that lists factors of a positive integer entered by the user. The number should be of type long
(64 bit two's complement).
-
The GUI will have a one line input text area of sufficient and
appropriate width
to enter a 64-bit two's complement positive integer.
-
The GUI will have a start/stop button that is used to start and
terminate the factoring process.
-
The initial text on the start/stop button is
Start
.
-
After the start button has been pressed (and the input has been validated)
it will turn into a stop button with the button text
Stop
.
-
Pressing stop button before
the factors are done being listed terminates the factoring but
leaves the GUI in tact and ready to be used again to list the factors
of another number.
-
After the stop button has been pressed it should turn back into a
start button.
-
The GUI application will have a button
Clear
that, when pressed,
clears the text in both the input and output window areas. This button should
be disabled during the factoring process and reenabled when factoring has
been completed, terminated, or paused.
-
If the factoring process terminates on its own (that is, it is done listing factors)
then the stop button turns back into a start button.
-
The GUI will have an output area that is scrollable. This area is where
factors are listed one per line. Hint: Look up the Swing class
JScrollPane
.
-
The user should not be allowed to type into the scrollable output area.
This area is for display purposes only.
-
The application will check to make sure that the input is valid. The only
valid input is a positive integer that can be represented as a Java
long
. Appropriate
error messages should be sent to the output area (the
same output area where factors are listed).
-
The application will also have a pause/resume button.
The factoring process
can take a long time to complete and the user should be able to pause the
process and then resume it.
-
The pause button should be initially disabled until the
factoring process starts.
-
After factoring starts the pause button should be enabled
and the button text should say
pause
.
-
After the start or resume button has been pressed
factors should be displayed to the output window as they are found.
Factors should not be displayed all at once in one big list after the
factoring process has completed.
-
If the factoring process terminates on its own (because it has finished
finding factors) the pause button should be disabled.
-
If the pause button was pressed then the button text should
change to resume.
-
Pressing the resume button should continue
listing factors where the factoring
process left off and the
button text should toggle back to pause.
-
Closing the application window should terminate the Java process
(the JVM that was running).
-
The GUI widgets (buttons, text areas, etc.) should follow a sensible layout.
The three buttons should appear next to each other and should not
separate from each other.
-
Each GUI widget (button, text area) should have an appropriate tool tip
associated with it.
Program Design and Implementation Requirements
This section lists some requirements on how your program should be designed and implemented.
-
This program must be implemented using the Java Swing
classes and Java threads.
-
The application should be well structured using classes where appropriate
to abstract and modularize your code. Follow the MVC design pattern.
Hint: use a separate
JPanel
class for your buttons. Use a separate class for each button,
and output text area. Use a separate JPanel
class that
brings all of the GUI components together.
-
The code that factors a number should be in its own class (the model).
It should be
a
Runnable
that blocks the factoring process (waits) when the pause button
was pushed and resumes factoring when resume is pushed. However,
your factoring class (the model) should have no knowledge about
buttons, text areas (or any
of the Swing classes for that matter) and should not need to import those
classes.
-
Documentation:
Every class should have a descriptive comment explaining its purpose.
-
Documentation: Every method should have a descriptive comment
explaining its purpose, parameters, return values, and weakest preconditions.
-
Documentation: All data members should have an
appropriate comment describing their purpose.
-
All methods, data members, and classes should have appropriate
visibility (private, protected, public, or package).
-
The program printout should have no bad line breaks.
Extra Credit
For up to an additional 10% on this project grade (two points on your final average)
figure out how to add a progress bar to your application.
Hint: take a look at the JProgressBar
Swing class. The progress bar should behave linearly. That is when 50% of the possible factors have been checked the progress bar should be half way filled in.
You are only eligible for the extra credit if you satisfy
the functional requirements specified above.