Bueno ahora me encuentro con otro problema que desastre :S
ya que tengo el programa y me va tanto la entrada como la salida, pero en la salida me da un error con privacy.
restricted
12,javi,j101,Wed Oct 01 00:00:00 CET 1975,barcelona,ES
unsupported country
4,xx,xman,Sat Sep 26 00:00:00 CET 1970,tarragona,ES
5,zz,zman,Sun Dec 12 00:00:00 CET 1965,lleida,ES
y deberia dar
restricted
12,javi,j101,Wed Oct 01 00:00:00 CET 1975,barcelona,ES
unsupported country
Information about user not allowed
5,zz,zman
Y este es el código que llevo hasta ahora:
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
import static java.lang.Math.*;
public class Person {
private int idUser;
private String username;
private String realname;
private Date birthDate;
private String locality;
private String country;
private int privacy;
public Person(int idUser, String username, String realname,
String locality, Date birthDate, int privacy, String country) {
this.idUser = idUser;
this.username = username;
this.realname = realname;
this.birthDate = birthDate;
this.locality = locality;
this.country = country;
this.privacy = privacy;
}
public int getIdUser() {
return idUser;
}
public void setIdUser(int idUser) {
this.idUser = idUser;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getRealname() {
return this.realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public String getLocality() {
return this.locality;
}
public void setLocality(String locality) {
this.locality = locality;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
enum privacyLevel{ ALLPUBLIC, NOSENSIBLEDATA, ALLRESTRICTED;}
private int ALLPUBLIC = 0;
private int NOSENSIBLEDATA =1;
private int ALLRESTRICTED =2;
int privacyLevel( int ALLPUBLIC, int NOSENSIBLEDATA, int ALLRESTRICTED){
this.ALLPUBLIC= 0;
this.NOSENSIBLEDATA= 1;
return this.ALLRESTRICTED= 2;
}
public int getPrivacy() {
return privacy;
}
public int getchanguePrivacyLevelto(int privacyLevel) {
if (privacyLevel >2){
privacyLevel = privacy;
}else{
return getchanguePrivacyLevelto(privacyLevel);
}
return privacy;
}
public int setchanguePrivacyLevelto(int privacyLevel) {
return this.privacy = privacyLevel;
}
public Void setBirthDate(Date birthDate) {
return null;
}
public Date getBirthDate() {
return this.birthDate;
}
public boolean equals(Object anObject) {
int p2 = idUser;
int p3 = idUser;
if ((p2 != p3)) {
return true;
}
return false;
}
public String toString() {
// Format Date date = new Date();
StringBuffer sb = new StringBuffer();
GregorianCalendar cal = new GregorianCalendar();
Locale loc = new Locale("ES");
Calendar hoy = Calendar.getInstance();
hoy.add(Calendar.YEAR, -17);
if (getCountry()!= Locale("ES")){
sb.append("unsupported country");
}
else{
if (getPrivacy() > 2 && getPrivacy() != 1){
sb.append("Information about user not allowed");
}
if (getBirthDate().after(hoy.getTime())
|| getBirthDate().equals(hoy.getTime())) {
sb.append("restricted");
}
else{
// sb.append(System.getProperty("line.separator"));
sb.append(this.getIdUser() + "," + this.username + "," + this.realname
+ "," + getBirthDate() + "," + getLocality() + ","
+ getCountry());
}
}
return sb.toString();
}
private String Locale(String country) {
// TODO Auto-generated method stub
return country;
}
}
Y no sé dónde estoy fallando, o que es lo que me falta. ¿Alguién podria ayudarme please? Muchisimas gracias ante todo.