DOC PREVIEW
UNF COP 2551 - Study Notes

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

InputsOutputsDeliverablesProgram #6COP 2551_706Fall 2005 Note: This program will be run using the JGrasp IDE in a Windows environment.This will use: STRINGTOKENIZER; EXTERNAL FILES; ARRAYLIST OF STRINGS AND OBJECTS. ITERATORS, EXCEPTION HANDLERSObjectives:- Gain additional experience using multiple classes - To gain experience with sorting objects- To gain additional experience processing arrays of objects- To gain experience with inheritance - To gain experience using abstract classes- To gain experience using polymorphism - To gain experience with Exception Handlers (optional; extra credit) - To gain more experience with UML and program design using classes. Background: Consider program in your text at the end of Chapter 8 on Inheritance. It reads: Design and implement a set of classes that define various types of reading material: books, novels, magazines, technical journals, textbooks, and so on. Include data values that describe various attributes of the material, such as the number of pages and the names of the primary characters. Include methods that are named appropriately for each class and that print an appropriate message. Create a main driver class to instantiate and exercise several of the classes.We will use this basic thinking to define a closely related programming assignment that is a bit more challenging and include some materials from Chapter 10 on exception handling and reading text files.Overview :Using records from an input file that you create (records provided ahead), you are to create three arrays of objects. Each array of objects are arrays of different types of books. You are to display each of these lists, sort each array of objects, and then display the arrays of types of books again.In a little more detail, you will need to access the external file, read in records, access individual fields, determine the appropriate array the input data should be put into, build the arrays of different types of books, sort them based on author, and display these lists with appropriate headers. If you elect to accommodate the Exception processing, your input stream will contain a couple of records containing errors. In this case, you will need to catch these exceptions and process them accordingly (ahead). (You may remove the two records containing errors, if you wish. Exception processing may be undertaken for extra credit.). If this is your choice, then the file you create should contain no errors dealing with the data itself. No editing of input fields will be necessary. Of course, any I/O can generate an IOException,, as you are aware from Program #5.PROCESSINGWrite a program that accepts text input from a file called books.txt. This file is to contain ‘records’ that youwill read and process (that is, load into three different arrays of objects depending on the kind of record youread in). You will need to define this external file, read each token (field) in each record using String Tokenizer, and build a number of arrays of objects for the particular ‘type’ of book you read in. The data for book.txt is shown ahead. You may, if you wish, supplement the records in book.txt with additional‘books’ if you wish. But do not exclude the records I am sending to you. Again, please note that there will be inputs in books.txt that will cause exceptions. But you may remove those if you elect to not undertake your own Exception processing. We will discuss how to handling these exceptions ahead in this description. There will be three types of books: Books, TechJournals, and TextBooks. You will be creating an array of objects for each of these types. (Think aggregate in UML.). The three types of books are to inherit from a base class (parent class) named ReadingMaterial.java, which is to possess common attributes. ReadingMaterial.java is to be an abstract class and will support inheritance and polymorphism. Common attributes you should define in ReadingMaterials should be numPages and authors. BE CERTAIN TO DRAW YOUR DESIGN USING UML FIRST, AS THIS WILL CLEARLY SUPPORT YOUR DETAILED PROGRAM DESIGN, ONCE YOU ESTABLISH THIS ARCHITECTURAL (PRELIMINARY) DESIGN.Your input file, books.txt will contain the attribute values for each type of reading material and a code that you will use to determine which of the three types of reading materials you have just read (so that you may load this object into its appropriate array).You should not write your program to be dependent upon the number of input records you will process. You may handle additional records by either using ArrayList class (as mentioned) or by increasing the size of the respective arrays through an increaseSize() routine, as we have done in the past. This is your choice. You are to display a report header (ahead) plus a second sub-header citing: “Books” and then the list of books you have; then a subheader: “Technical Journals” followed by the list of technical journals you have created, and lastly, the subheader Textbooks followed by the list of textbooks.Once this is accommodated, you are then to sort each array using any method you choose. Recommend an interchange or exchange sort that you may use almost directly from your textbook. Most of you did this in Program 5. (If you wish, you may use the Comparable interface and then implement this.) When the arrays are each sorted, you are to generate the same report again. (Hence you may use the same procedure and the same methods passing arrays of objects that have been rearranged by the sorts.Attributes that are to appear in your base class (ReadingMaterial.java) must include:authors, a String, and numpages, an integer.You will also have at least one abstract method entitled displayHoldings.. A number of supporting methodsand attributes will be found in derived classes, Book.java, TechJournal.java, and TextBook.java. (Please use these file names, as it will assist me in setting up a batch file to compile and test your program.)displayHoldings is to be implemented as a polymorphic reference to sort each of the arrays of reading materials and to display all of the reading materials.(Write exception handlers for any publications that do not have number of pages (last field). Write an exception handler for textbooks that do not include ISBN attribute. Display a suitable method, but do not stop processing.)Remember: - an interface can have no method definitions (that is, the code body) – only


View Full Document

UNF COP 2551 - Study Notes

Download Study Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?