i have this dataRecorder class that has my getters and setters and i need to produce a class that makes it interactive and saves the details entered to a txt file, and then make another record after the first details entered
the class datarecorder is as follows aswell i have to link it to GUI with the textfield details being saved to the file aswell they are all linked
import java.util.*;
import java.io.*;
import java.text.*;
public class DataRecorder
{
static BufferedReader keyboard = new
BufferedReader (new InputStreamReader(System.in));
static PrintWriter screen = new PrintWriter(System.out,true);
private String BadgeNo;
private String CarRego;
private String CarType;
private String CarColour;
private String Located;
static private int objCount = 0;
public DataRecorder()
{
incrementCount();
BadgeNo = "No Badge number entered";
CarRego = "No Car Registration entered";
CarType = "No Manufacturer entered";
CarColour = "No Colour entered";
Located = "No location entered";
}// end of consructor
public DataRecorder(String aBadgeNo, String aCarRego,String aCarType, String aCarColour, String aLocated)
{
incrementCount();
BadgeNo = aBadgeNo;
CarRego = aCarRego;
CarType = aCarType;
CarColour = aCarColour;
Located = aLocated;
}//end of constructor
// start of getters
private static void incrementCount()
{
objCount = objCount + 1;
}//end of incrementCount
public static int getObjCount()
{
return objCount;
}
public String getBadgeNo()
{
return BadgeNo;
}// end of getBadgeNo
public String getCarRego()
{
return CarRego;
}// end of getcarrego
public String getCarType()
{
return CarType;
}// end of getcartype
public String getCarColour()
{
return CarColour;
}// end of getcarcolour
public String getLocated()
{
return Located;
}// end of getLocated
//setters
public void setBadgeNo(String astring)
{
BadgeNo = astring;
}// end of setCarColour
public void setCarRego(String astring)
{
CarRego = astring;
}//end of setCarrego
public void setCarType(String astring)
{
CarType = astring;
}// end of setcartype
public void setCarColour(String astring)
{
CarColour = astring;
}// end of setCarColour
public void setLocated(String astring)
{
Located = astring;
}// end of setCarColour
public String getTime()
{
String astring;
GregorianCalendar now = new GregorianCalendar();
astring = now.get(Calendar.HOUR_OF_DAY)
+ ":" + now.get(Calendar.MINUTE);
if(now.get(Calendar.MINUTE) < 10)
astring = now.get(Calendar.HOUR_OF_DAY)
+ ":" + "0" +now.get(Calendar.MINUTE);
return astring;
}
public String getDate()
{
String astring;
GregorianCalendar now = new GregorianCalendar();
astring = now.get(Calendar.DAY_OF_MONTH) + "/" + now.get(Calendar.MONTH)
+ "/" + now.get(Calendar.YEAR);
return astring;
}
public String getFine()
{
int finehour = 19;
int fine = 0;
int starttime = 0;
int endtime = 30;
GregorianCalendar presenttime = new GregorianCalendar();
if(finehour == presenttime.get(Calendar.HOUR_OF_DAY) && presenttime.get(Calendar.MINUTE) <= endtime
&& presenttime.get(Calendar.MINUTE) >= starttime)
{
fine = 30;
}
else
{
fine = 20;
}
String astring = String.valueOf(fine);
return astring;
}// end of method to calculate fine
public String toString()
{
String tempString = "";
tempString = tempString + getTime() + "\n" + getDate() + "\n" +
"Badge Number" + getBadgeNo() + "\n" + "Car Registration is " + getCarRego() + "\n" + "Car Manufacturer " + getCarType()+ "\n"
+ "Car Colour is " + getCarColour() + "\n" + "Car Location " + getLocated() + "\n" + "Fine : \u0153" + getFine() + "\n";
return tempString;
}//end of toString
}
the class datarecorder is as follows aswell i have to link it to GUI with the textfield details being saved to the file aswell they are all linked
import java.util.*;
import java.io.*;
import java.text.*;
public class DataRecorder
{
static BufferedReader keyboard = new
BufferedReader (new InputStreamReader(System.in));
static PrintWriter screen = new PrintWriter(System.out,true);
private String BadgeNo;
private String CarRego;
private String CarType;
private String CarColour;
private String Located;
static private int objCount = 0;
public DataRecorder()
{
incrementCount();
BadgeNo = "No Badge number entered";
CarRego = "No Car Registration entered";
CarType = "No Manufacturer entered";
CarColour = "No Colour entered";
Located = "No location entered";
}// end of consructor
public DataRecorder(String aBadgeNo, String aCarRego,String aCarType, String aCarColour, String aLocated)
{
incrementCount();
BadgeNo = aBadgeNo;
CarRego = aCarRego;
CarType = aCarType;
CarColour = aCarColour;
Located = aLocated;
}//end of constructor
// start of getters
private static void incrementCount()
{
objCount = objCount + 1;
}//end of incrementCount
public static int getObjCount()
{
return objCount;
}
public String getBadgeNo()
{
return BadgeNo;
}// end of getBadgeNo
public String getCarRego()
{
return CarRego;
}// end of getcarrego
public String getCarType()
{
return CarType;
}// end of getcartype
public String getCarColour()
{
return CarColour;
}// end of getcarcolour
public String getLocated()
{
return Located;
}// end of getLocated
//setters
public void setBadgeNo(String astring)
{
BadgeNo = astring;
}// end of setCarColour
public void setCarRego(String astring)
{
CarRego = astring;
}//end of setCarrego
public void setCarType(String astring)
{
CarType = astring;
}// end of setcartype
public void setCarColour(String astring)
{
CarColour = astring;
}// end of setCarColour
public void setLocated(String astring)
{
Located = astring;
}// end of setCarColour
public String getTime()
{
String astring;
GregorianCalendar now = new GregorianCalendar();
astring = now.get(Calendar.HOUR_OF_DAY)
+ ":" + now.get(Calendar.MINUTE);
if(now.get(Calendar.MINUTE) < 10)
astring = now.get(Calendar.HOUR_OF_DAY)
+ ":" + "0" +now.get(Calendar.MINUTE);
return astring;
}
public String getDate()
{
String astring;
GregorianCalendar now = new GregorianCalendar();
astring = now.get(Calendar.DAY_OF_MONTH) + "/" + now.get(Calendar.MONTH)
+ "/" + now.get(Calendar.YEAR);
return astring;
}
public String getFine()
{
int finehour = 19;
int fine = 0;
int starttime = 0;
int endtime = 30;
GregorianCalendar presenttime = new GregorianCalendar();
if(finehour == presenttime.get(Calendar.HOUR_OF_DAY) && presenttime.get(Calendar.MINUTE) <= endtime
&& presenttime.get(Calendar.MINUTE) >= starttime)
{
fine = 30;
}
else
{
fine = 20;
}
String astring = String.valueOf(fine);
return astring;
}// end of method to calculate fine
public String toString()
{
String tempString = "";
tempString = tempString + getTime() + "\n" + getDate() + "\n" +
"Badge Number" + getBadgeNo() + "\n" + "Car Registration is " + getCarRego() + "\n" + "Car Manufacturer " + getCarType()+ "\n"
+ "Car Colour is " + getCarColour() + "\n" + "Car Location " + getLocated() + "\n" + "Fine : \u0153" + getFine() + "\n";
return tempString;
}//end of toString
}