/* -------------------------------------------------------- * * Aaron Morris * * CS567 * * Object-Oriented Event-Driven Simulation * * * * Class representing Reporting Object * * -------------------------------------------------------- */ //package datasend; import java.awt.*; import java.io.*; public class Report { protected boolean echo; // Write to screen? protected FileOutputStream outFile; // Output file protected PrintStream p; // PrintStream -where to print to protected CS522App app; // Pointer to GUI for output // Basic Constructor -- Open Output file public Report(String FileName,boolean Echo,CS522App app) { this.app = app; this.echo = Echo; try { outFile = new FileOutputStream(FileName); p = new PrintStream( outFile ); } catch (Exception e) { System.err.println ("Error opening output file"); } } // Generic Method to write String to output file public void write(String outputText) { if (this.echo) app.getOutputArea().append("\n " + outputText); p.println(outputText); } // Method to close the output file and print stream when done public void closeReport() { try { outFile.close(); p.close(); } catch (Exception e) { System.err.println("Error Closing Files"); } } }