-
objects in txt files
Hello, i want to parse the objects of a class in a txt file. I want to build the method in the class write_in_file but i don t want to parse only the variables of the class but the specific form of the method showClass(showIstorikoAsthenous). Also i want to have access to the variables so i can read all the variables separately. How can i accomplish with that???
the following code is the class istorikoAsthenous:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ofthalmiatreio;
import java.util.*;
import java.text.*;
/**
*
* @author kris
*/
public class istorikoAsthenous extends Asthenhs {
private String astheneies;
private String sintages;
private int day;
private int month;
private int year;
DateFormat customFormat =
new SimpleDateFormat("dd MMM yyyy");
DateFormat mediumFormat =
DateFormat.getDateInstance(DateFormat.MEDIUM);
istorikoAsthenous(istorikoAsthenous ob){
super(ob);
astheneies=ob.astheneies;
sintages=ob.sintages;
day=ob.day;
month=ob.month;
year=ob.year;
}
public istorikoAsthenous(){
astheneies="NULL";
sintages="NULL";
day=0;
month=0;
year=0;
}
public istorikoAsthenous(String astheneies, int day, int month, int year, String sintages, String epwnymo, String onoma, int tilefwno, String asForeas){
super(epwnymo, onoma, tilefwno, asForeas);
this.astheneies=astheneies;
this.day=day;
this.month=month;
this.year=year;
this.sintages=sintages;
}
public void setAstheneies(String asth){
astheneies=asth;
}
public String getAsteneies(){
return astheneies;
}
public void setDay(int day){
day=Calendar.DATE;
this.day=day;
}
public int getDay(){
return day;
}
public void setMonth(int month){
month=Calendar.MONTH;
this.month=month;
}
public int getMonth(){
return month;
}
public void setYear(int year){
year=Calendar.YEAR;
this.year=year;
}
public int getYear(){
return year;
}
public void setSintages(String sint){
sintages=sint;
}
public String getSintages(){
return sintages;
}
public void setImpathisi(int day, int month, int year) {
this.day=day;
this.month=month;
this.year=year;
}
private Date getDate() {
Calendar calendar = Calendar.getInstance();
int year = getYear();
int month = getMonth(); // [0 - 11] 12 -> 0
int day = getDay();
calendar.set(year, month, day);
Date date = calendar.getTime();
return date;
}
public String getCustomFormattedDate() {
return customFormat.format(getDate());
}
public String getMediumFormattedDate() {
return mediumFormat.format(getDate());
}
public void showIstoriko(){
System.out.println("Ta stoixeia tou asthenh einai:");
System.out.println("-----------------------------------------------------------");
System.out.println("To onomatepwnymo tou asthenh einai: "+getOnoma()+" "+getEpwnymo());
System.out.println("-----------------------------------------------------------");
System.out.println("To tilefwno tou asthenh einai: "+getTilefwno());
System.out.println("-----------------------------------------------------------");
System.out.println("O asfalistikos foreas tou asthenh einai: "+getasForeas());
System.out.println("-----------------------------------------------------------");
System.out.println("H pathisi tou asthenous einai: "+astheneies);
System.out.println("-----------------------------------------------------------");
System.out.println("H imerominia eksetasis einai: "+ day +"/"+ month+"/"+year);
System.out.println("date: " + getDate());
System.out.println("custom formatted date: " +
getCustomFormattedDate());
System.out.println("medium formatted date: " +
getMediumFormattedDate());
System.out.println("-----------------------------------------------------------");
System.out.println("I sintagi tou giatrou:"+sintages);
System.out.println("-----------------------------------------------------------");
}
public static void main(String [] args){
istorikoAsthenous a= new istorikoAsthenous();
a.setAstheneies("mywpia");
a.setImpathisi(12, 5, 2008);
a.setSintages("glass");
a.setEpwnymo("Michael");
a.setOnoma("George");
a.setTilefwno(47508);
a.setasForeas("IKA");
a.showIstoriko();
}
}
Thank you for the time.:rolleyes: