
import java.awt.*;
import java.net.*;
import java.io.*;
import marimba.channel.*;
import marimba.gui.*;
import marimba.io.*;

public class TaxesApplication extends ApplicationPlayerFrame {

String src = "values.txt";

public void start() {
   super.start();
	readValues();
}

public void stop() {
	super.stop();
	writeValues();
}

public void readValues() {
	File vfile = new File(context.getDataDirectory(), src);
	if (vfile.exists(src)) {
		try {
			FastInputStream fs = new FastInputStream(vfile);
	  		
			util.setValue("wages", fs.readLine());  	// wages & salary
			util.setValue("int", fs.readLine());  		// interest & dividends
			util.setValue("business", fs.readLine()); // business income
			util.setValue("capgains", fs.readLine()); // captial gains
			util.setValue("otherinc", fs.readLine()); // other income
			util.setValue("deduct", fs.readLine());   // deductions
			util.setValue("exempt", fs.readLine());  	// exemptions
			util.setValue("credits", fs.readLine());  // credits
			util.setValue("withhold", fs.readLine()); // withholding
			util.setValue("estpayment", fs.readLine()); // estimated payments
 
 		fs.close();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}
}

public void writeValues() {
	File vfile = new File(context.getDataDirectory(), src);
	try {
		FastOutputStream fs = new FastOutputStream(vfile);

		fs.println(util.getValue("wages"));  	// wages & salary
		fs.println(util.getValue("int"));  		// interest & dividends
		fs.println(util.getValue("business")); // business income
		fs.println(util.getValue("capgains")); // captial gains
		fs.println(util.getValue("otherinc")); // other income
		fs.println(util.getValue("deduct"));   // deductions
		fs.println(util.getValue("exempt"));  	// exemptions
		fs.println(util.getValue("credits"));  // credits
		fs.println(util.getValue("withhold")); // withholding
		fs.println(util.getValue("estpayment")); // estimated payments

		fs.close();
	}
	catch (IOException e) {
		e.printStackTrace();
	}
}

}

