package calendar;
import java.util.Calendar;
public class Contact extends CsvStructure {
private int m_id;
private String m_name;
private Calendar m_dob;
private String m_landphone;
private String m_mobilephone;
private String m_workphone;
private String m_email;
private String m_workemail;
private String m_website;
public static final int NO_FIELDS = 9;
public static final int IDX_ID = 0;
public static final int IDX_NAME = 1;
public static final int IDX_DOB = 2;
public static final int IDX_LANDPHONE = 3;
public static final int IDX_MOBILEPHONE = 4;
public static final int IDX_WORKPHONE = 5;
public static final int IDX_EMAIL = 6;
public static final int IDX_WORKEMAIL = 7;
public static final int IDX_WEBSITE = 8;
return m_dob;
}
public void SetDob(Calendar dob) {
m_dob = dob;
}
return m_email;
}
m_email = email;
}
return m_id;
}
public void SetId(
int id) {
m_id = id;
}
return m_landphone;
}
m_landphone = landphone;
}
return m_mobilephone;
}
m_mobilephone = mobilephone;
}
return m_name;
}
m_name = name;
}
return m_workemail;
}
m_workemail = workemail;
}
return m_workphone;
}
m_workphone = workphone;
}
return m_website;
}
m_website = website;
}
m_id = 0;
m_name = ".";
m_dob = Calendar.getInstance();
m_landphone = ".";
m_mobilephone = ".";
m_workphone = ".";
m_email = ".";
m_workemail = ".";
m_website = ".";
}
public Contact(
int m_id, String m_name, Calendar m_dob, String m_landphone
, String m_mobilephone, String m_workphone, String m_email,
String m_workemail, String website) {
this.m_id = m_id;
this.m_name = m_name;
this.m_website = website;
try {
if(ValidDob(m_dob)==true)
this.m_dob = m_dob;
else
throw new Exception();
if (ValidLandphone(m_landphone) == true)
this.m_landphone = m_landphone;
else
throw new Exception();
if (ValidMobilephone(m_mobilephone)==true)
this.m_mobilephone = m_mobilephone;
else
throw new Exception();
if (ValidWorkphone(m_workphone)==true)
this.m_workphone = m_workphone;
else
throw new Exception();
if (ValidEmail(m_email)==true)
this.m_email = m_email;
else
throw new Exception();
if (ValidWorkemail(m_workemail)==true)
this.m_workemail = m_workemail;
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
String csv = m_id+",\""+m_name+"\","+"\""+Data.FromDate(m_dob)+"\",\""+
m_landphone+"\",\""+m_mobilephone+"\",\""+m_workphone+"\","+"\""+
m_email+"\",\""+m_workemail+"\""+",\""+m_website+"\"";
return csv;
}
if (dob.equals("")){
System.out.println("Please enter a valid dob " +
"(1 or more characters)");
return false;
}
return true;
}
if (mobilephone.equals("")){
System.out.println("Please enter a valid mobilephone number" +
"(1 or more characters)");
return false;
}
return true;
}
if (landphone.equals("")){
System.out.println("Please enter a valid landphonenumber " +
"(1 or more characters)");
return false;
}
return true;
}
if (workphone.equals("")){
System.out.println("Please enter a valid workphone " +
"(1 or more characters)");
return false;
}
return true;
}
if (email.equals("")){
System.out.println("Please enter a valid email " +
"(1 or more characters)");
return false;
}
return true;
}
if (workemail.equals("")){
System.out.println("Please enter a valid workemail " +
"(1 or more characters)");
return false;
}
return true;
}
}