CSci 211: File Systems
Fall Semester 1996
Assignment #3


Due Date

I change the due date to Wednesday, 30 October, at 2:30 p.m. It is my intention to apply a 5% per day late penalty beyond that point.

The original due date was Wednesday, 23 October 1996, 2:30 p.m.

Objective

To give you practice in the implementation of ADTs (classes) in Java given relatively detailed interface specifications.

Technical Report Record

This assignment develops ADTs for manipulating "records" about the Departmental technical reports. Each record includes the following information:

report identifier:
This field contains a valid identifier for the record.

A valid report identifier is 6 characters in length. It begins with a non-space character. All alphabetic characters are in lowercase.

This is the key field for the record. That is, it should uniquely identify the record within a collection of all reports of interest.

authors:
This field contains the names of the authors of the report. If there are multiple authors, the names are separated by ampersands "&".

title:
This field contains the title of the report.

publication date:
This field contains the month and year of original publication, followed by the dates of any revisions. A revision date should be separated from the dates preceding it by an ampersand "&".

Part 1: ADT for Technical Report Identifiers

Design and implement a Java class ReportId for storing and manipulating the report identifiers as described above.

Each instance of the ReportId class must preserve the following invariant:
Once created, this instance contains a valid report identifier.

Include methods with the following signatures and semantics in the class.

public ReportId(String id)
Precondition:
id is a valid report identifier string, except that it may contain extra leading or trailing spaces and consist of a mixture of upper- and lowercase characters.
Postcondition:
The new instance of ReportId is initialized to hold id, with leading and unnecessary trailing spaces removed and all alphabetic characters replaced by their lowercase equivalents.
public int compareTo(ReportId r)
Precondition: True
Postcondition:
The returned value is the result of a lexicographic comparison of the report identifier for this instance with the report identifier for instance r. The value returned is 0 if they are equal, -1 if this instance is less than r, or 1 if this instance is greater than r.
public String toString()
Precondition: True
Postcondition:
Returns this instance's identifier as a String.

You should design, implement, and test this class by itself before integrating it with remainder of the program.

Part 2: ADT for Technical Report Records

Design and implement a Java class Report for storing and manipulating the technical report "records" as described above.

Each instance of the Report class must preserve the following invariant:
Once created, this instance contains a valid technical report record. (Valid technical report records must have valid report identifiers and have otherwise consistent representations.)

Include methods with the following signatures and semantics in the class.

public Report(ReportId id)
Precondition:
id is a valid report identifier.
Postcondition:
The new instance's key field, report identifier, is initialized to bew id. All other fields have reasonable default values.
public void setAuthor(String newAuthor)
Precondition: True
Postcondition:
This instance's author is set to newAuthor.
public void setTitle(String newTitle)
Precondition: True
Postcondition:
This instance's title is set to newTitle.
public void setPubDate(String newPubDate)
Precondition: True
Postcondition:
This instance's publication date is set to newPubDate.
public ReportId getKey()
Precondition: True
Postcondition:
Returns this instance's key field, the report identifier.
public String getAuthor()
Precondition: True
Postcondition:
Returns this instance's author field.
public String getTitle()
Precondition: True
Postcondition:
Returns this instance's title field.
public String getPubDate()
Precondition: True
Postcondition:
Returns this instance's publication date.
public String toString()
Precondition: True
Postcondition:
Returns this instance's entire report record as a string in printable format.

You should design, implement, and test this class and integrate it with the ReportId implementation before integrating it with the remainder of the program.

Part 3: Table of Technical Report Records

Design and implement a Java class ReportTable for storing and manipulating a collection of technical report "records".

Each instance of the ReportTable class must preserve the following invariant:
Once created and until destroyed, this instance of ReportTable contains a valid collection of valid report records. (No key occurs more than once in a valid collection. The internal representation is otherwise consistent.)

Include methods with the following signatures and semantics in the class.

public ReportTable(int size)
Precondition:
size >= 0
Postcondition:
The new instance is initialized so that it can hold up to size technical report "records"; it is empty initially.
public void insert(Report r)
Precondition:
r is a valid report record. This instance's collection is not full. A record with key getKey(r) does not occur in the collection.
Postcondition:
Report record r inserted into the collection.
public void delete(ReportId id)
Precondition:
id is a valid report identifier. This instance's collection is not empty. A record with key id occurs in the collection.
Postcondition:
The report record with key id is removed from the collection.
public void print(PrintStream os)
Precondition:
os is an open print stream.
Postcondition:
This instance's entire collection of report records printed to print stream os. (The records may be printed in any order that is convenient with the internal representation.)
public Report retrieve(ReportId id)
Precondition:
id is a valid report identifier. This instance is not empty. A report record with key id occurs in the collection.
Postcondition:
Returns the report record with key id from the collection. (The collection is not modified.)
public boolean isIn(ReportId id)
Precondition:
id is a valid report identifier.
Postcondition:
Returns true iff a report record with key id occurs in this instance's collection.
public boolean empty()
Precondition: True
Postcondition:
Returns true iff this instance's collection contains no records (i.e., is empty).
public boolean full()
Precondition: True
Postcondition:
Returns true iff this instance has no space for additional records (i.e., is at full capacity).
public void destroy()
Precondition: True
Postcondition:
The internal resources used by this instance are released. In essence, the instance no longer exists.

You should design, implement, and test this class and integrate it with the Report and ReportId implementations before integrating it with the remainder of the program.

Part 4: An Application Using Table

Processing

Design and implement a Java driver program that:

Input File Format

The input file report.txt will be available from the URL ftp://ftp.cs.olemiss.edu/pub/csci211/assignments/report.txt. This is a text file containing information about a set of Departmental technical reports (many real, some imaginary). You may assume that there are no more than 100 reports described in the input file.

The data on each report are recorded as a group of five consecutive lines. All "fields" described below begin in the first character position on the line (i.e., they are left-justified).

  1. start flag -- the two characters "$$" beginning a line
  2. report identifier
  3. authors
  4. title
  5. month/year of publication & revisions

Submitting Your Assignment

Once you have completed the program:


UP to CSci 211 Assignments page?


Copyright © 1996, H. Conrad Cunningham
Last modified: 119 December 1996.