| CIT
591 Assignment
8: Study Fall 2005, David Matuszek |
Purposes of this assignment:
General idea of the assignment:
People often have to learn pairs of things that go together (in psychological jargon, paired associates). Given one of them (the stimulus), the person has to come up with the other (the response). For example:
Dr. Dave; response:
8-8122)Pennsylvania;
response: Harrisburg)mountain; response:
der Berg)6 * 9;
response: 54 (or 42 for HHG fans))As your customer, I want a program to help me memorize lists of things--for example, German vocabulary words. In addition, I want a program to help me construct these lists in the first place.
Details:
Item classAn item is a single pair of things to learn (for example, Pennsylvania
and Harrisburg). In addition to the stimulus and response, an item
keeps track of how many times in a row it has been answered correctly (as a
rough measure of how well the item has been "learned.") The Item
class should have the following capabilities:
| Method | Purpose |
|---|---|
public Item(String stimulus, String response) |
Constructor; the number of times correct will be initialized to zero. |
|
Setter and getter methods; timesCorrect returns the number
of times in a row that this item has been answered correctly. |
public void mark(Boolean correct) |
Keeps track of the number of times in a row that this item was answered
correctly (true indicates a correct answer, false
an incorrect answer). |
StudyList classThe most important component of the StudyList class is a list
of items to be studied. Your class will keep these items in an ArrayList
(java.util.ArrayList), which has the important feature that it
can grow as you add items. Declare and define your array list with the following
somewhat unusual syntax:
ArrayList<Item> studyList = new ArrayList<Item>();
Except for constructing the list, you do not need any unusual syntax. You can
explore the API for methods to use with an ArrayList, but most
or all of your work will be done with the ListIterator (see below).
Your StudyList class should have the following capabilities:
| Method | Purpose |
|---|---|
public StudyList() |
Constructor |
public void load(File file) |
Read in a list of items from the given You can assume that the file being read in has the correct syntax. |
public void save(File file) |
Save the item list to the given File, one Item
per line, with separating
the parts. |
public ListIterator listIterator() |
Simply gets and returns a ListIterator for the underlying
ArrayList. The returned iterator has operations add(Item),
remove(), hasNext(), next(), hasPrevious(),
and previous(), among others; you can use this iterator to
directly manipulate the items in the study list. See the Java API for java.util.ListIterator
for details. |
StudyListEditor classThe StudyListEditor is a Swing-based application (with a main
method) for editing study lists. Only one study is edited at a time. The StudyListEditor
GUI should have the following controls:
|
It is important for the programmer to realize that there can be a difference
between the item information displayed on the screen and what is actually in
the Item. The user should not have to know about this. Hence, almost
any action (except typing into a text field) should cause the program to check
the inputs and update items appropriately, before the action is taken.
Stimulus and response values should be trimmed (use String method
trim()) before being stored in the Item. An "empty"
stimulus or response field (one that is zero length after being trimmed) should,
in most cases, cause a warning message to be displayed and the requested operation
to be aborted. (It should be OK to delete an item with empty fields.) To minimize
code duplication, I suggest the use of a private boolean method to do this checking.
Study class Study is a Swing-based application (with a main
method) for helping the user memorize study lists. The display should be as
follows:
|
An item is considered to be "learned" when the user gets it correct a certain number of times (say, 3) in a row. Learned items are kept in the study list, but are not ever presented to the user.
When all items have been learned and there is nothing more to display, the program should bring up a dialog box to so inform the user. The user should be given an opportunity to save the study list. The program does not quit automatically at this point, because the user may wish to use a different study list.
Do JUnit testing on the Item class. The StudyListEditor
and Study classes are basically GUI classes, and must be tested
by hand. The StudyList class reads and saves files, and returns
a ListIterator for the internal ArrayList; again,
nothing much to test.
One member of your team should write the StudyListEditor class
and the other member should write the Study class (these are both
basically GUI classes, of roughly comparable difficulty.) If you have no partner,
you can omit the StudyListEditor class. Use @author
tags to specify who did which class.
One member of your team should write the load method and the other
the save method, so that each of you gets some experience with
file I/O. @author tags do not apply to individual methods, but
you can put your name in an ordinary comment.
Due date:
Thursday, November 17, before midnight. As usual, please submit one zip file, via Blackboard, containing all necessary files.