Question: Need help with this question Here's the copy-pastable code: import java.io.IOException; import static java.lang.System.*; public class CoolSet7_1 { public static void main( String args[] )

Need help with this question

Need help with this question Here's the copy-pastable code: import java.io.IOException; import

static java.lang.System.*; public class CoolSet7_1 { public static void main( String args[]

Here's the copy-pastable code:

import java.io.IOException; import static java.lang.System.*; public class CoolSet7_1 { public static void main( String args[] ) throws IOException { String word; FileInput inFile = new FileInput( "coolset7-1.dat" ); word = inFile.readLine(); if( inFile.fileFound() ) { try { while( !inFile.eof() ) { word = inFile.readLine(); FancyWord goal = new FancyWord(word); out.println(goal); out.println(); } }catch( Exception n ) { System.out.println( " End of file" ); } } } }

2. Write program FancyWord to work with the driver program shown below. Notice that each instance of FancyWord, called goal, is displayed by the line out.println(goal) This means that your FancyWord class will have to have a toString method that converts a String matrix (or a matrix of String objects) into a single String object and returns this String object. Keep in mind that a string object can contain escape characters such as " ". import java.io.IOException; import static java.lang.System.; public class CoolSet7_1 public static void main(String args[]) throws IOException coolset 7-1.dat" ); String word; FileInput inFile = new FileInput( word = inFile.readLine(); if( infile.fileFound()) try while( linfile.eof() ) word = inFile.readLine(); FancyWord goal = new FancyWord (word); out.println(goal); out.println(); }catch( Exceptionn) { System.out.println(" End of file"); } atau "coolset7-1.dat" HELLO CAT DOGHOUSE PARANGARACUTIRIMICUARO NEWPORT GOOGLE Basically, when the driver reads a word that word is used to create a FancyWord object. The FancyWord constructor creates a square 2D array (using the number of letters in the word) and fills each String element in the array with a single-letter String object or a space (" "). The toString method uses the elements of the 2D array to form a single String object which is returned to out.print() in the driver and displays an hourglass using this word. SAMPLE OUTPUT PARANGARACUTIRIMICUARO NEWPORT E R WO WO ER NEWPORT Po36. sotda oz a da EE PARANGARACUTIRIMICUARO

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!