Object-Oriented Programming…………………………. 1

Object-Oriented Programming…………………………. 1

Write a method named justifyJava that takes three parameters: an input file name, an output file name, and a tab size. Use the provided code, JavaJustifier.java, and add your code to the body of justifyJava. Be sure to put the provided test data in the same folder as your java code. The test data consists of input files and reference files that contain the expected results. public static void justifyJava( String inputFileName, String outputFileName, int tabSize ) throws FileNotFoundException { /* your code goes here */ } The method should assume that the input file contains a Java program. The method opens the input file and reads the input file line by line and prints each line to System.out and to the output file with {}-blocks properly indented. First Step: In the method justifyJava, write code to open the input file for reading, then loop through the file line by line, to print out the entire input file. Second Step: In the method justifyJava, write code to open the output file for writing, then add code to the loop you created in the first step to write, line by line, to the output file. Third Step: In the method justifyJava, write code to implement proper indentation. Fourth Step: Uncomment the code in main that will verify your work. You should get Success for file n for each of the test files. Proper indentation is as follows: ? The first line of a program must have no spaces before the first non-white space character. See Note 1 below. ? Whenever a line has a }, that line must be indented one “tab” less than the previous line. See Note 2 below. ? Whenever a line has a {, the next line must be indented one “tab” more than the current line. See Note 3 below. ? Between the first non-white space character and the last non-white space character, the characters in the line should not be changed. Note 1: The class String has a method named trim that removes leading and trailing white space. So if a String named str was ” abc “, str = str.trim(); would change str to “abc”. Note 2: Example: line = line.substring( tabSize ); The above code will remove tabSize spaces from the beginning of the String named line. Note 3: We can add one tab to the beginning of a line as follows: Example: line = one_tab + line

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30


WHATSAPP CHAT: +1 (781) 253-4162


Click ORDER NOW..

order custom paper