Computer program
420-P26-GG Programming Object I
date: Wednesday, May 19th before 11:55 pm - no delay allowed
Learning objec�ves
• Apply the basic concepts of object-oriented programming to concrete problems • Apply the
concept of encapsula�on
• Apply the overall concept of classes
• Apply good excep�on handling
• Use Java u�li�es
• Implement interfaces
• Use file read / write
• Use java.nio.file classes
Direct access to the defini�on of a word from the dic�onary on a file
text type
Note: This is an educa�onal project, to put certain concepts into prac�ce and keep everything
fairly simple. Respect what is asked here to earn points, even if you think doing otherwise
would be be�er. In a professional implementa�on, we probably wouldn't do things this way
As input, we have a text file " defini�ons.txt " whose one-line format is:
word: defini�on
For example:
Java: very nice language object programming
The aim of this exercise is to consult the dic�onary. To make it easier to find words in
the dic�onary, we are going to create a direct access file " defini�ons.txt.sbc " from
the "file defini�ons.txt " . The “file defini�ons.txt.sbc ”only contains the defini�ons
(no end of line, etc.). We are also going to create an index table whose content of an
entry is:
word displacement length
where:
Project XXXXXXXXXXP26-GG Page 1 of 5
Project 3
to be submi�ed before Wednesday,
May 19, 11:55 p.m. No delay
accepted Delivery
• word is the search word
• displacement is the byte where the defini�on of the word in the direct access
file “ defini�ons.txt.sbc ”
• length is the number of bytes in the defini�on.
For example:
Java XXXXXXXXXX
Means that the defini�on of the word " Java " is at byte XXXXXXXXXXwith a length of XXXXXXXXXXbytes
in the file " defini�ons.txt.sbc "
To perform this job you must use at least the following classes (all instance variables
are private, there is noclass public variables)in a set of classes ( "package") project3:
____________________________________________________________________
theclass Entree that contains:
• theprivate instance word variables, displacement and length
• A constructor which ini�alizes the instance variables using values received as
arguments
• Amethod toString XXXXXXXXXXwhich allows to display an object of type Input
• A String readDefini�on (SeekableByteChannel sbc) method which returns the
defini�on of the cu
ent entry (you must posi�on yourself in the direct access
file).
• Amethod getMot XXXXXXXXXXwhich returns the word of the cu
ent entry. Add the other "
ge�ers ", there should be no " se�ers ".
____________________________________________________________________
In ansub- package index_v1 (therefore project3.index_v1 ), theclass Index which
contains:
• A private instance variable tableIndex of type HasMap declared as follows:
private HashMap
tableIndex = new HashMap ();
word object the L'Entree is used as a key in the HashMap.
• A constructor which only displays: " ====== index with HashMap ========="
• Anmethod addEntry that adds e to tableIndex. You should put the word used as
the key in uppercase in the index, but not modify the word read in the file or
at the console in the object e
Project XXXXXXXXXXP26-GG Page 2 of 5
• Anmethod EntersearchEntry (String word) which returns the entry
co
esponding to the word word if it exists in the table and returns null if no
entry contains the word word. The
eakage does not ma�er.
• Do not use