I have an assignment and I need some help with it. This is the assignment
//
Research reports are often required to conform to a given standard such as APA or MLA. These standards specify things like the size of the margins and formats for titles, paragraphs, references, page numbers, etc. Suppose that a program is to produce a report conforming to a standard. It would be desirable to provide utility class to automatically conform to these standards. That way the application need only be concerned about supplying the content. The utility class would provide methods such as printParagraph(String test), printTitle(String title), printReference(String author, String title, int year, String publisher), printLine(String) and breakPage().
Develop a utility class to provide the above listed methods. Define a constructor for the class that takes number of columns in a page, number of lines in a page, and the author’s name. The class is to perform the following formatting:
1- 5 spaces for left and right margin
2- first line of every page after the first page is to print left justified the authors name and page number.
3- the second and third lines (at the top), and the last 5 lines of each page are to be blank. The first line of the first page is also blank.
4- the print title is to center the title across the page. Note the tile may contain embedded new line characters, if so center and print each line. A blank line is to follow the title.
5- the printParagraph is to perform word wrap. The first line of the paragraph is to be indented 5 spaces.
6- the printReference is to format a reference paragraph. That is the paragraph is to have a comma between each item, perform word wrap if needed with a hanging indent of 5 spaces on lines past the first. A blank line is printed after a reference.
7- the breakPage() method will print enough blank lines to complete the current page.
Have your printLine method throw a RuntimeException in the event that the String passed exceeds the available number of columns (i.e. number of columns in a page less the margins.
Include getter methods to get the instance variables (e.g. include a getAuthor() so that the class can to printTitle(getAuthor()) to add the author centered as a title.
Write a test program to thoroughly test your class.
Bonus 3 points: Allow and additional left and right margin to be specified. Thus if a user wanted to format a paragraph that had an extra indent on both the left and right, their program could call the methods to set the indent before print paragraph then reset the extra margin to 0 afterwards. If you do this task make sure you have a test case that demonstrates it is working correctly.
This is the class that I did:
Expand|Select|Wrap|Line Numbers
- public class Utility {
- private int columns;
- private int lines;
- private String author;
- Utility (int col, int lin, String aut){
- columns = col;
- lines = lin;
- author = aut;
- }
- public void printParagraph(String test){
- }
- public void printTitle(String title){
- }
- public void printReference(String author, String title, int year, String publisher){
- }
- public void printLine(String line){
- }
- public void breakPage(){
- }
- }