CO523 (fundamentals of programming and logic) |
[ assessment5 | technical | submission ]
The purpose of this assessment is to give you some experience with using existing Java classes. The Java API (application programming interface) provides a wealth of packages (what are generally known as libraries in other languages), covering a huge range of things (networking, XML, regular expressions, graphics and GUIs, file I/O, plus hundreds of other things). Some packages are quite specialised, some are generally useful.
In doing this assessment, you will find the Java 1.5 API most helpful. The "Java in Two Semesters" book is also quite useful.
To get started, you will need to download and unpack the following BlueJ project: (I'd suggest placing it on your Raptor file-space -- mapped to a suitable drive-letter on your Public PC windows desktop [or study-bedroom connection] -- more disk space available there than on your "Z:" [usually bodiam]).
This implements a 'library' system (books) for a hypothetical University. The notable features are:
This assessment is split into stages. The stages need not necessarily be completed in the order specified (some do, however). The final stage is optional -- near perfect solutions to the other stages will get you 100% (theoretically, not many people manage it in practice!), but marks for that final stage can make up for lost marks on the other stages.
The "Library" class has a method called 'findBook', which searches through the list of books for the one specified as a parameter. This works and is used by the 'preloadLibrary' method (which populates the library with some default information). The "Library" class also contains a 'findPerson' method, but this is incomplete. For this stage, you should finish the implementation of the 'findPerson' method.
[this stage is worth 15% of the marks]
The 'preloadLibrary' method in "Library" calls "Book.readFromFile ("books.txt", this)" to read the book descriptions from a file and have them added to the library; whereas the students and staff are created 'by-hand' and stored in local variables. For this stage, you should add the following method to "Student":
/** * reads in student data from a formatted text-file. * For each student read in, adds them to the specified library * * @param filename the filename to read from * @param lib the library to add students to * * @return 0 on success, non-zero on failure */ public static int readFromFile (String filename, Library lib) { ... your code here }
[this stage is worth 20% of the marks]
The third stage requires the first two to be mostly complete. For this stage, you should modify the code in the "Library" class's 'preloadLibrary' method to call 'Student.readFromFile ("students.txt", this)', and remove the two "Student" local variables. This will also require using the 'findPerson' method when creating the "LoanRecord" objects. You'll also need to create a file called "students.txt" in the project directory and put some default student data in it. Note: leave the "Staff" alone in 'preloadLibrary()', just change the "Student" handling.
[this stage is worth 20% of the marks]
The "Library" class currently needs to search through all of the books in 'findBook()', because it uses an "ArrayList" to store those books, and similarly for people and loan-records. Modify the code in "Library" so that "HashMap"s are used instead of "ArrayList"s for storing books, people and loan-records. With reference to the HashMap documentation, use the book's title for its hash, a person's name for people, and the due-date for loan-records. You will need to add a suitable accessor method to the "LoanRecord" class to extract the due-date. For this stage, do not modify the 'findBook' (and 'findPerson' if you have already done it) methods.
[this stage is worth 25% of the marks]
Complete the previous stage by changing the code in the 'findBook' and 'findPerson' methods so that they do not need to do an exhaustive search through the various items.
[this stage is worth 20% of the marks]
This stage is entirely optional, but I'd recommend having a go at it anyway (it doesn't depend on the previous stages particularly). The "LibraryGUI" class implements the beginnings of some simple GUI functionality. All it does at the moment is produce a bunch of "JButton"s inside a "JFrame". You can try this out by right-clicking the 'LibraryGUI' box in BlueJ and creating a new instance of it. The 'report' button currently dumps the library "database" to the standard output.
For this stage, create a new class called "LibraryReport" that extends "JFrame" and implements "ActionListener" that displays the same contents are output at the moment (getting the text by calling the "Library" class's 'toString' method). You'll need to use some suitable text-display component for doing this, and there is lots of information on-line about how to do this. For instance, the Swing tutorial's text-components page. Various Java text-books have illustrations and example code relating to these sorts of things -- I'd suggest having a look at them!
If you want to go even further (though there will be no extra marks for this), change the layout so that it displays books, people and loan-records separately. You'll need to add suitable accessor methods to the "Library" class to extract the book/people/loan-record information.
[this stage is worth up to an extra 25%]
When you've completed as much as you can, zip the BlueJ project folder ('library-gui') up and place it in the directory "/proj/co523/assess5/login/" on raptor (where login is replaced with your login!). From Windows, this will appear as "r:\proj\co523\assess5\login\" (where r: is the drive mapped to "\\raptor\files\"). If for whatever reason you cannot place your zipfile on raptor, email it as an attachment to frmb@kent.ac.uk.
Please make sure that all stages are catered for in the final code you submit (or as much as you have done).
The deadline for submission is 11pm on Monday 23rd November (week 9).
If you aim to complete one and a half stages per week, then this coursework should not be a burden and there will be plenty of time to get help if you need it. I.e. don't leave it to the last minute!. As a rough guide, this assessment should take up to 12 hours -- some of which will be coding, some of which will be reading on-line documentation.
Submission: The penalty for late or non submission of coursework is normally that a mark of zero is awarded for the missing piece of work and the final mark for the module is calculated accordingly.
Plagiarism and Duplication of Material: You are reminded of the University rules concerning plagiarism and duplication of material and are advised to consult the Plagiarism and Collaboration Frequently Asked Questions (FAQ). The Computing Laboratory reserves the right to apply checks to programs submitted for assignment in order to guard against plagiarism and to use programs submitted to test and refine our plagiarism detection methods both during the course and in the future.
Extensions: If you are unable to submit required coursework because of illness or other reasonable cause you must report the reason without delay to your tutor and the person who set the assessment. It is up to the person who set the assessment, in consultation with your tutor, to decide whether or not to grant an extension.
Last modified 30th October 2009 |