import javax.swing.JOptionPane;
import java.io.*;
//This class will accept perameters and write the information into a file
public class WriteToFile
{
String Name, Address,CoverCheckBox,HeaterCheckBox,InGroundCheckBox,AboveGroundCheckBoxPool,
PoolCheckBox, SpaCheckBox, SpaCoverCheckBox, HotTubCheckBox, HotTubCoverCheckBox,
HotTubincludeCheckBox, HotTubAGroundCheckBox;
public WriteToFile()
{
}
public WriteToFile(String name, String address, boolean coverCheckBox, boolean heaterCheckBox,
boolean inGroundCheckBox, boolean aboveGroundCheckBoxPool, boolean poolCheckBox, boolean spaCheckBox,
boolean spaCoverCheckBox, boolean hotTubCheckBox, boolean hotTubCoverCheckBox, boolean hotTubincludeCheckBox,
boolean hotTubAGroundCheckBox ) throws IOException
{
String str;
Name = name;
Address = address;
//The boolString method returns the boolean as a string value
CoverCheckBox = boolString(coverCheckBox);
HeaterCheckBox = boolString(heaterCheckBox);
InGroundCheckBox = boolString(inGroundCheckBox);
AboveGroundCheckBoxPool = boolString(aboveGroundCheckBoxPool);
PoolCheckBox = boolString(poolCheckBox);
SpaCheckBox = boolString(spaCheckBox);
SpaCoverCheckBox = boolString(spaCoverCheckBox);
HotTubCheckBox = boolString(hotTubCheckBox);
HotTubCoverCheckBox = boolString(hotTubCoverCheckBox);
HotTubincludeCheckBox = boolString(hotTubincludeCheckBox);
HotTubAGroundCheckBox = boolString(hotTubAGroundCheckBox);
str = Name + "," + Address + "," + CoverCheckBox + "," + HeaterCheckBox + ","
+ "," + InGroundCheckBox + "," + AboveGroundCheckBoxPool + "," + PoolCheckBox
+ "," + SpaCheckBox + "," + SpaCoverCheckBox + "," + HotTubCheckBox + "," + HotTubCoverCheckBox
+ "," + HotTubincludeCheckBox + "," + HotTubAGroundCheckBox;
try
{
FileWriter writer = new FileWriter("customerInfo.dat", true);
writer.write(str);
writer.close();
}
catch (FileNotFoundException e)
{
JOptionPane.showMessageDialog(null, "Sorry an unexpected"
+ "error occured");
}
}//End contructor
public static String boolString(boolean x)
{
String str;
if (x == true)
{
str = "true";
}
else
{
str = "false";
}
return str;
}//End boolString method
}//End class
This post has been edited by jon.kiparsky: 19 August 2012 - 04:01 PM

New Topic/Question
Reply



MultiQuote



|