My current code will generate a txt file that includes "Instrument [i] : " and then the boolean values (true or false) of the four methods that I've created. However, I want the text file to include output such as this here. Any help is greatly appreciated.
cello1 is tuned. cello1.tuneInstrument = (boolean value)
cello1 is playing. cello1.playInstrument = (boolean value)
cello1 is not playing. cello1.stopPlaying = (boolean value)
cello1 is ready for concert. cello1.readyConcert = (boolean value)
/*
*
*/
package instruments;
import java.io.File;
import java.io.FileNotFoundException;
public class TestInstruments {
public static void main(String[] args) throws FileNotFoundException{
Instruments cello = new Instruments();
File file = new File("AshleyMasonp3test.txt");
if (file.exists()){
System.out.println("File already exists");
System.exit(0);
}
try (java.io.PrintWriter output = new java.io.PrintWriter(file)) {
int i = 1;
while (i < 11) {
System.out.println("Instrument " + i + ":");
output.println("Instrument " + i + ":");
output.println(cello.tuneInstrument());
output.println(cello.playInstrument());
output.println(cello.stopPlaying());
output.println(cello.readyConcert());
i++;
}
}
}
}