• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

Java-Programmed Library System

Extracts from this document...


The Library System

Joel Goncalves

Computer Science (Bsc)

Abstract        A simple information system for the school library was designed, where records of books could be added, deleted or printed to the screen.  The classes Record and Library were created in order to represent the main purpose of the project, which was storing information regarding a particular book in a collection of book records allocated in the Library class.  From the Library class we can access these records, edit them, or get the data contained in them.  We can also get a list of all the records in the collection printed out to the screen.

1.  Introduction

The laboratory session was carried out with the use of a programming utility for Java named BlueJ.  The theory, and main objective, of java programming is the interaction between objects.  An object is regarded as an instance of a class, which can be seen as a set of instructions towards  the construction and interactivity of the object - its data and behaviour.  So while a class is responsible for characterising the objects, these are in charge of interacting with other objects (defined by other classes), if that is the programmer’s will.  

In this lab session only 2 classes were used, Library and Record. The programming environment in which this laboratory was produced can be witnessed in the figure below.  The objects are represented by the red rectangles in the bottom, while the two classes in use are above the objects, respectively named.

...read more.





Code sample 2: The BookRecord constructor

Code reprinted from the .java document on this specific lab (BookRecord.java by Joao R. Goncalves)

This code sample uses Java exception handling to keep track of possible errors, for later debugging, if necessary.  The other methods in the class were simple accessor methods designed to return the value contained in a specific field.  For example, methods such as getAuthor(), getTitle() and getYear() returned the author name, title of the book and year of publication, respectively.  This makes it possible for other classes to access the information of the one in question, without allowing them to edit or delete the values of the fields (unless we instruct the fields to be “editable” by other classes, by making them public instead of private).

3.  The Library class

In this class we want to store all the books, be able to edit or delete them, as well as print information regarding those books.  For the purpose of managing the books in the library created an ArrayList where we could add the books using the method addBookRecord().  This method took four parameters in order to create a Book object and add it to the list.  We would also like to get all of the books printed out, so a listAllBooks() method was implemented, which would present us with the list in case there were any books inserted.

...read more.


            if(title != null)

                if(book.getTitle() != title)

                    found = false;

            // If both tests have been passed, print book







        // Print footer

        if(booksfound == 0)


        System.out.println("End of query.");




Code sample 2: The Library Class

Code reprinted from the .java document on this specific lab (Library.java by Joao R. Goncalves)

Some tests were run after the library class was complete, in order to determine if these were working properly.  These included adding records to the book list, and then printing them to the screen, as well as searching the list for a specific book or author.  To carry out these functionality tests, some books were added to the Library using the addBookRecord(), and then the listAll() method was executed, which printed the results in Figure 2.  The queryBookList method was then called, to retrieve the books written by the author Peter Grossman, and the output can be checked in Figure 3.  The images of the results of the tests are available below:


Figure 2: The list of books in the ArrayList


Figure 3: The search results for books by Peter Grossman

4.  Conclusions

The laboratory session provided useful knowledge on the use of data collection objects such as ArrayList’s, as well as methods to iterate through them in order to retrieve data.  Also, the interaction between objects becomes clearer, as it is the main idea behind object-oriented programming languages such as Java or C++.

5.  References

COMP1004 – Programming Principles lab 3 challenge specifications on project B.  Viewed on 28-10-04 at https://secure.ecs.soton.ac.uk/notes/comp1004/Resources/Week3/lab03.html


...read more.

This student written piece of work is one of many that can be found in our University Degree Computer Science section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related University Degree Computer Science essays

  1. The project explains various algorithms that are exercised to recognize the characters present on ...

    Using file I/O operation, this text file is copied in a 2-dimensional array and each of these vectors are compared in their respective quadrant during template matching. The complete sequence of this flow is as shown in the Figure 3.8.

  2. Unix Shell Programming

    '/' AND '%' OPERATOR:- SOURCE CODE echo Read the dividend: read dividend echo Read the divider: read divider i=0 while[ $dividend -ge $divider] do dividend=`expr $dividend - $diviser` i='expr $i + 1' done echo The quotient is $i echo The remainder is $dividend OUTPUT Read the dividend: 17 Read the

  1. Lifecycle Management Of Information Technology Project In Construction

    a? being far more independent than they actually are. In?tead, project management approache? ?hould ?trive to make interdependencie? between work ta?k? more explicit. (Battin 2001:70)Thi? doe? not increa?e interdependence and complexity, but it doe? make exi?ting interdependency and complexity more vi?ible, and therefore more manageable. In ?ummary, con?truction project?

  2. Some of these calculations can be complex and errors arise. In order to aid ...

    * Details of the multiplying factors also need to be looked up. * Cost of quote needs to be calculated with and without any no claims bonus. * The customer details that need to be entered into the quotes worksheet will be looked up from a customer number.


    Revolutionary changes in quality can happen only when the entire organization is tuned into excellence and working to improve performance in every area of the operation. Nothing less is acceptable. 5. Training: Each of the organization provides its people with ongoing training in every aspect of quality.

  2. So in order to understand what the main areas where organisation should be aware ...

    The Internet Engineering Task Force (IETF) is working on DNS security extensions to increase security within the DNS, known as DNSSEC. These security issues and solutions are presented in this paper. The threats that surround the DNS are due in part to the lack of authenticity and integrity checking of

  1. System Specifications

    x86 infrastructure while allowing for a smooth migration to 64-bit operating systems and applications as soon as they become market ready. Overview of the key benefits for our company include: * Two 200-series AMD Opteron processors * Up to 16GB of PC3200 Memory (eight dimm slots, 2GB Dimms when available)

  2. The treatment of the class system in Miss Julie by August Strindberg.

    The normal solution of premarital sexual relationship for people is to get married, but because of class barriers, Jean and Miss Julie can never get married. Actually, if Miss Julie and Jean do not divulge the secret, no one would know their liaison and they can still lead a normal life in the town.

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work