PROJECT 1

Implement a program to:

  • use a GUI interface to control and display the results of the program,
  • read a text data file, 
  • instantiate appropriate classes, 
  • create an appropriate internal (multi-tree) data structure, 
  • display the structure in a convincing way using a JTextArea, and 
  • search the structure. 

Elaboration:

The scenario is inspired by a LIbrary Management System (LIMS). For the first version of the project, the LIMS is a very basic one, allowing just for the import of data from a text file and perform some basic search operations.

The elements of the LIMS are: the Library itself (let's consider just one instance for now) that contains a collection of Authors. Each Author includes a collection of Books he/she published.

The Author and Book classes will have some attributes, mainly used for searching and sorting.

  1. Required data structure - the data structure I want you to implement is a multi-tree with the following levels:
    1. Library - Level 0
    2. Author - Level 1
    3. Book - Level 2
  2. Class specifications
    • Library
      • ArrayList <Author> as an instance variable data structure
    • Author - index, a name, an address and list of a number of Books (accessed by links to instances of the Book class). 
      • ArrayList <Book> as an instance variable data structure
    • Book - index, a title, a genre, author by index
  1. Use the ArrayList class to hold instances of the classes defined in item 1. Be sure to use generics appropriately.
  2. Use a text data file with the following format - which you may extend. As a minimum, each item should be specified by a single line in the data file. The initial fields should be used during the instantiation of objects and your program should ignore later fields that are not used. The fields are separated by colons. The specifications look like the following, where the angle brackets are not part of the actual data file. We can assume that name, address, title and genre are strings.
    • b:<index>:<title>:<genre>:<price>:<author_index>
    • a:<index>:<name>:<address>

Your program should 

  • work if there are additional fields on some lines,
  • ignore blank lines,
  • ignore lines starting with a / (as comments),
  • accept spaces within names and types, and
  • ignore extra spaces around the :'s nicely.
  1. All the classes should be provided with appropriate:
    • constructors
    • toString implementations
    • additional methods
    • instance variables connecting the class to appropriate instances of other classes
  1. A GUI that will allow the user to do at least the following operations:
    • Select the data file at run time, using JFileChooser starting at dot.
    • Show the internal data structures in a text area
    • Search for an item by index, title or genre. For example, the book whose title is "Java Basics".
    • Resize nicely in a JFrame.

Deliverables

  1. Java source code files WITH DETAILED COMMENTS
  2. any configuration files used including your data file

Format

Sample data file:

// sample data file
// Student name
// Date
// Books format:
//    b:<index>:<title>:<genre>:<price>:<author_index>
b : 10001 : Java Basics : Science : 11.50 : 20001
b : 10002 : Advanced Java : Science : 10.99 : 20001

// Authors format:
//    a:<index>:<name>:<address>
a : 20001 : John Smith : Computers St. 50 Seattle 
a : 20002 : Mary Jones : Literature Lane 25

 

    • 11 years ago
    the answer
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      answer.zip