CIT 590 Assignment 9: Paired Associate Learning
Spring 2009, David Matuszek
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))This is a version of a program I wrote long ago (and have rewritten several times). Because the main point of this assignment is learning to build GUIs, I have greatly simplified the program by not keeping track of the student's progress. There are two parts to the assignment, each with its own GUI:
When I am "studying," here's what I want to see:
The program should do something to get my attention when I make an error (for example, turn something red).
I can quit the program at any time.
The program does not remember whether I get items right or wrong, nor does it make any intelligent choices of what stimulus to present next. (This is part of the simplification that I mentioned earlier.)
At the beginning of a study session, the data is read in from a file. Each
item on the file consists of: the stimulus, a double bar (||),
and the response. For example (English-Japanese):
I want || hoshii desu
I don't want || hoshiku arimasen
now || ima
yes (casual) || ee
at my place || watashi no tokoro de
at your place || anata no tokoro de
you are skilled || jozu desu
I am not skilled. || Jozu ja arimasen.
The program then randomly chooses a fairly small number
of pairs to use (15 or 20; should be a single final variable)
and ignores the rest. trim() all strings, so that the student
does not have to "learn" which words have leading and/or trailing spaces.
In addition to helping the student study, the program should help the teacher build lists of paired items. There are three basic operations that should be implemented:
The GUI classes, which handle interaction
with the user, must do no, repeat no,
manipulation of the data in any way. All they do is handle events and call
methods in the StudyList class. As far as the GUIs are concerned,
they have no idea what their buttons, text fields, and other widgets
are being used for.
There are two GUI classes, StudyGui and ListEditorGui.
Each has a main method.
What the program does depends on which class the program is started from.
The model classes, Item and StudyList,
do all the computational work (in this case, all the I/O and list manipulation).
They do not access the GUIs in any way. In fact,
if the GUIs were removed from the project, this would not result in any syntax
errors in these classes.
The StudyList class also acts as an
intermediary in any file I/O--if a GUI wants a file loaded or saved, it asks
StudyList to do that. If Exceptions occur, the GUI class (not
the StudyList class) should display an informative Message Dialog to the
user, then continue as if nothing had happened.
class StudyGui
class ListEditorGui
class Item
Each stimulus/response/count item should be an object. Let's call
this an Item. Each Item should have a way of editing
its stimulus and response parts (getter and setter methods should be good enough
for this).
class StudyList
The StudyList class does no printing or GUI work--it just
keeps track of data. Data consists of all the Items from
the file, and an array of those items (maybe 15 or 20) currently being studied.
Each member of your team should do one of the GUIs, and to specify (with the
@author tag in the class) who did each GUI. Both of you should
work together on the model classes. Your grade will be based 50% on your part
and 50% on the whole thing.
This is a team programming assignment. It's not quite a pair programming project, because each of you is responsible for part of the code, and both of you are responsible for part of it. However, the program has to work. Programs that don't work are worth zero points. So in order to get credit for your GUI--not only the layout, but also the work it does--the program as a whole has to work.
Since the StudyList contains some methods that will mostly be
used by the StudyGui and others that will mostly be used by the
ListEditorGui, you might want to divide up the work along these
lines.
I recommend that you spend the lab period deciding who does what parts, and making a very specific outline of class responsibilities (suggestions given above), constructors, method names, and parameters. Work together as much as you can, including helping each other with GUIs as necessary.
PairedAssociateLearningpackage pairedAssociateLearning class StudyGui extends JFrame
public static void main(String[] args) class ListEditorGui extends JFrame
public static void main(String[] args)
class Item
Item(String stimulus, String response) // constructorpublic
String getStimulus()public void putStimulus(String stimulus)public String getResponse()public void putResponse(String response) class StudyList
public void add(Item item)public Item find(String stimulusOrResponse)public void delete(Item item)public void modify(Item item, String newStimulus,
String newResponse)
public void load()
throws IOException
load method in SimpleIO, and
catches any Exceptions that are thrown.public void save()
throws IOException
save method in SimpleIO, and
catches any Exceptions that are thrown. public void load saveAs()
throws IOException
saveAs method in SimpleIO, and
catches any Exceptions that are thrown.class SimpleIO (provided)
public static ArrayList<String> load() throws IOException
line.split(" *\\|\\| *") will
break line into an array of those two Strings. public static void save(ArrayList<String> lines)
throws IOExceptionpublic static void saveAs(ArrayList<String> lines) throws
IOException Item and StudyList. PairedAssociateLearning_yourName_partnersName The above are requirements. You may have additional classes and methods as needed, and they should be documented and unit tested as appropriate.
Thursday, April 2, before midnight, via Blackboard. Please submit one zip file containing all necessary files.