• 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...

Introduction

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.

Middle

            System.out.println();

        }

    }

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.

Conclusion

            if(title != null)

                if(book.getTitle() != title)

                    found = false;

            // If both tests have been passed, print book

            if(found)

            {

                book.printDetails();

                booksfound++;

            }

        }

        // Print footer

        if(booksfound == 0)

            System.out.println("None.");

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

        System.out.println();

    }

}

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:

image02.png

Figure 2: The list of books in the ArrayList

image03.png

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

image00.png

...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. Lifecycle Management Of Information Technology Project In Construction

    to the typical project ?cheduling proce??, where re?ult? are repre?ented in the CPM network. (Ebert 2001:62) � The key inter-relation?hip? between view? would be defined. Thi? would be analogou? to way that precedence relation?hip? are captured in the ?chedule, or way that the ?chedule can be mapped to co?t account?, re?ource plan?, or to the building information model (a?

  2. Create an online catalogue system that specialises in children's toys and enables users to ...

    Figure 4.1 The Two Tier Architecture (Shamos 2000) 4.1 Database Design This section will discuss the steps undertaken to produce an effective database which will be used as the back-end of the Toyland web site. Now that the system requirements have been uncovered it is possible to design the database management system (DBMS), which will be the back end of the Toyland web site.

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

    Therefore, the LPR systems designed are country specific and are adapted to the country specification. In US, every state has its own laws and rules governing the license plates. Hence, the first step in implementing the LPR System is to decide in which state the design has to be implemented.

  2. Unix Shell Programming

    -:PROGRAM TO CHECK A NAME WHEATHER IT IS A PALINDROME OR NOT:- SOURCE CODE echo Enter a name: read name cct = ' expr $name|wc -c ' cct = ' expr $cct -1 ' flag = 0 i = 1 j = $cct while [ $i -le $j ] do

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

    Quotes Worksheet: the interface that the end-user will be working with in order to make quotes. 4. Multipliers Worksheet: used to make the calculations for a quote, again subject to change. 5. Customers Worksheet: stored quotes used for further reference. 6. Data Worksheet: a temporary store of quotes. 7.

  2. System Specifications

    (See Appendix A) * Memory: Supports up to 16GB of PC3200 operating up to 12.8GB/sec * Network: 10/100/1000-Mbps Base-T Gigabit Ethernet * Input/Output: Five USB 2.0 Ports, two IEEE1934 (Firewire) ports, one parallel port and two serial ports. * Graphics: NVIDIA Quadro FX3000 Graphics Accelerator.

  1. 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

  2. TOTAL QUALITY MANAGEMENT SYSTEM

    The people who are recognized for global class quality communicate that it requires approximately siz years of hard work before the program is really cooking. 2. Goals: These companies have extremely ambitious goals that are not based on what they might be able to do, but on the achievements of other organizations that have been successful.

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