DOC PREVIEW
UNF COP 2551 - Study Notes

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 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 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

InputsOutputsProgram #5COP 2551Summer 2007 Note: This program will be run using the NetBeans 5.5 IDE in a Windows environment.This will use: StringTokenizer or substring, external files, the ArrayList Class, multidimensional arrays, and exception handlers. This program will also provide practical issues with inheritance, polymorphism, and also affords additional UML and pseudocode design practice. If you choose to include exception handling, there will be a twenty point bonus! See details below.. 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. (some of these might be in a base class, while other attributes might be in derived classes.) Include methods that are named appropriately for each class and that print an appropriate message. Create a main driver class to instantiateand exercise several of the classes.We will use this basic thinking to define a closely related programming assignment that isa bit more challenging and include some materials from Chapter 10 on exception handling and reading text files.Overview:1. Create your own input file from data provided below. Using data provided below, you are to build your own input file called books .txt and place it into your project directory. More ahead, but the first character of each formattells the ‘type’ of book / manuscript that the following text represents. You will use this in 2 ahead.2. Build arrays from this input file. Using records from an input file that you created in the previous task, (records are provided ahead), you are to read the single input file youcreate, and from this file create three arrays of objects, one for each type of book. You are to pass the input file (that is, ‘read’ the input file) only one time. Each record is to be examined to determine the type of record it is, and to determine which of the three arrays the object you create will be placed in. (You may need StringTokenizer or substring or other methods / classes as you may determine.)3. Display the three arrays. After building the three arrays, you are to display each of these lists. Each list is to have a very nice ‘header,’ skip a line, and print the entries in‘that’ array very nicely formatted, that means columns that line up, etc. (single space these entries). In a little more detail, you will need to access the external file, read in records, access individual fields, determine the appropriate array that the input data should be put into, build the arrays of different types of book objects and display these lists with appropriateheaders. Bonus. 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 alternatively remove the tworecords containing errors, if you wish and proceed without these ‘error records’ in your input file. Once you get the main program running correctly, you may add these records back in and attempt the bonus option, if you wish. Exception processing may be undertaken for extra credit.). If your choice is to not try the exception handling, then the file you create should contain no errors dealing with the data itself. You may eliminate the two records with errors. No editing of input fields will be necessary. Of course, any I/O can generate an IOException,, as you are aware from Program #4. More Processing Description. The input data described ahead include 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, which is to possess common attributes. ReadingMaterial 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 must not write your program to be dependent upon the number of input records you will process. You are to build the arrays using the ArrayList class. For your displaying of the arrays of each type of book, you will need 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. All of these are to be professionally aligned and displayed.Attributes that are to appear in your base class (ReadingMaterial) must include:authors, a String, and numpages, an integer.You will also have at least one abstract method entitled displayHoldings.. A number of supporting methods and attributes will be found in derived classes, Books, TechJournals, and TextBook. (Please build your application in NetBeans with each of these separate classes – not directly following the Main class. All, of course, will use the same package name.) displayHoldings is to be implemented as a polymorphic reference for displaying each of the arrays of 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.) Again, this is optional. Remember: - an interface can NOT be instantiated; can have no method definitions (that is, the code body) – only declarations; all methods are abstract; no instantiations (no objects). In fact, an interface is an interface and not a ‘class. ’ An interface can, however, contain constants, if needed.- an


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?