Assignment 11

CS 1181
Assignment 11

Reading

Chapter 9 of the text
Moodle:  Class Coding Style
Java Classes

Java Application – Chapter and ChapterReader

Chapter.java

Create a class to encapsulate the data and behavior of a chapter from Assignment 9.  The class should have something like the following fields:

Chapter Number – int
Chapter Title – String
Starting Page Number – int
Ending Page Number – int

Use appropriate access modifiers when defining the data

Code accessor and mutator (get and set) methods for all class instance variables. Be sure to follow the class style and use _<classInstanceVariable> as the name for the parameter corresponding to the class instance variable. (Note the “_” starting the parameter name.) You will need to make a method that returns the number of pages in the chapter.

If the chapter title is blank, or the values passed for the chapter number or page numbers are not valid, leave the associated instance variable unchanged.

ChapterReader.java

The main method in this class should read the table of contents from a text file named toc.txt and use the class mutators to put the information into the Chapter object. The Chapter object should then be passed to a method to display chapter information using the class accessors and member method.

toc.txt
The toc.txt file contains semi-colon delimited fields for the chapter number, title, starting page, and the ending page for each book chapter. Download this file from Moodle and use it in your application.

The program output should appear as shown here:

Chapter Title                                                        Page   Length
1 Introduction to Computers, Programming, and Java             1      32
2 Elementary Programming                                       33     42
3 Selections                                                   75     44
4 Mathematical Functions, Characters, and Strings              119    38
5 Loops                                                        157    46
6 Methods                                                      203    42
7 Single-Dimensional Arrays                                    245    42
8 Multidimensional Arrays                                      287    34
9 Objects and Classes                                          321    44
10 Object-Oriented Thinking                                     365    44
11 Inheritance and Polymorphism                                 409    40
12 Exception Handling and Text I/O                              449    46
13 Abstract Classes and Interfaces                              495    40
14 JavaFX Basics                                                535    50
15 Event-Driven Programming and Animations                      585    44
16 JavaFX UI Controls and Multimedia                            629    48
17 Binary I/O                                                   677    28
18 Recursion                                                    705    33

Grading Rubric

Chapter.java

•    Correct File Name (Chapter.java) – case sensitive
•    Correct Class Name (Chapter) – case sensitive
•    Correct Style – comments
•    Correct Style – indentation
•    Correct Style – White Space
•    Correct Style – Mutator parameters
•    Free of syntax errors
•    Private data for title, and start, end, and chapter numbers
•    Public accessors for title, and start, end, and chapter numbers
•    public mutators for title, and start, end, and chapter numbers
•    Validate input in mutators
•    public member method to return number of pages

ChapterReader.java

•    Correct File Name (ChapterReader.java) – case sensitive
•    Correct Class Name (ChapterReader) – case sensitive
•    Correct Style – comments
•    Correct Style – indentation
•    Correct Style – White Space
•    Free of syntax errors
•    Validate and properly encase file functions in a try-catch
•    Creating Chapter object
•    Reading chapter information from toc.txt file and using mutators to set chapter data into object
•    Pass chapter object to method to display report
•    Use Accessor methods in your method to display product information
•    Create a method for displaying chapter information.

find the cost of your paper