The peer assessment exercise and the reference exercises
This session is divided into two parts. The first part is the peer assessment exercise (which is a course assignment). The second part is about the exercises of the text version of the reference project.
The peer assessment
Aim
To get feedback on the first assignment and become familiar with the marking criteria of the fourth assignment
What to do
You will be a copy of someone else's script: one without marking as well as a marking sheet.
-
You need to mark the script. Work on the unmarked copy of the script following the instructions on the marking sheet.
-
Once everybody has returned the scripts then you will be able to retrieve your own set of script copies from the School Office (the one marked by the tutor as well as the one marked by a peer).
The Reference exercises
Aim
To understand and use hashmaps and subclasses
Reference exercises
These exercises are intended to give you a start with the fourth assignment, specifically with its text user interface. Before
you start make sure you understand what the assignment is about. You
can read about it in the fourth assignment pages.
-
a). The starting program, the project ReferenceTexta, implements all of the functionality of the glossary project apart from the user interface. One important difference between the Reference and the Glossary programs is that Reference handles not one but several Glossaries. One problem with the Glossary program is that the Glossary class, as well as defining the behaviour of a glossary, also stores its information (the terms). A sophisticated version of this class would store the terms externally (in a text file for example), but at this moment we will create subclasses of glossary for this (storing terms externally is an extension). Therefore the subclass will only be used to store the information of the specific type of glossary while the definition of its actual behaviour will remain in the parent class.
This exercise is therefore about creating two subclasses of Glossary so they can be used by reference in later exercises. The two subclasses to create are the JavaGlossary and the CppGlossary. The current Glossary class has term entries associated with the Java Glossary so the first thing to do is to create a new class, JavaGlossary, as a subclass of Glossary and transfer the term entries to it. Once this is done create an instance of JavaGlossary and inspect it to verify that the term entries are in there now. The next step is to create another new class, CppGlossary, as a subclass of Glossary and include in it the terms in the file cppGlossary.txt. Again create an instance of CppGlossary and inspect it to verify that the corresponding term entries are in there.
-
b). Create the Reference class that is going to handle all the glossaries. This class has to contain a collection as a field to store all the glossaries. Given that glossaries will be referenced by a unique label (see exercise d), the collection has to be a hash map (HashMap glossaries). The task is therefore to create the class, its constructor and the includeAllGlossaries() method. The constructor should initialise the glossaries hash map and invoke the method includeAllGlossaries() that will include instances of the two glossaries in the glossaries hash map.
-
c). Implement the method termExists in the Reference class. This method has one parameter (a string) and returns true if the parameter exists in any of the glossaries and false otherwise. The method has to look potentially in all of the glossaries but should terminate the search once the parameter has been found in one of them. You have to assume that there will be an unknown number of glossaries and therefore use a loop to iterate through them. Tip: this method should invoke the method termExists in the Glossary class.
-
d). Implement the method getTermDefinition in the Reference class. This method has one parameter (a string) and returns its definition. If the term exists in several glossaries all the definitions are returned, each preceded by the name of its glossary (this is one of the reasons why glossaries has to be a hash map). This method should also invoke the method getTermDefinition in the Glossary class.
-
e). Implement the method getSimilarTerms in the Reference class. This method has one parameter (a string) and returns all terms (an ArrayList of strings) from all the glossaries which are similar to the one specified as parameter. Again this method should invoke the method getSimilarTerms in the Glossary class.
-
Download the starting program (this is basically the same as the starting program for the fourth assignment).
| Last updated at 5:57pm, Thursday November 10th 2011 |
Dr Natalia Beloff (N.Beloff@sussex.ac.uk) |
|
|
|