Foros del Web » Programación para mayores de 30 ;) » Java »

problema con privacy

Estas en el tema de problema con privacy en el foro de Java en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 18/10/2010, 16:09
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
problema con privacy

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.
  #2 (permalink)  
Antiguo 19/10/2010, 01:10
Avatar de Fuzzylog  
Fecha de Ingreso: agosto-2008
Ubicación: En internet
Mensajes: 2.511
Antigüedad: 15 años, 8 meses
Puntos: 188
Respuesta: problema con privacy

if (getCountry()!= Locale("ES")){

sb.append("unsupported country");

}

else{ // En caso de que no haya pasado por el if anterior --> Y como estaba appended Sí ha pasado por el if anterior, ergo no accede al else.

if (getPrivacy() > 2 && getPrivacy() != 1){

sb.append("Information about user not allowed");

}

// Solución -> Deberías ver si es necesario el else o si tienes que repetir el if interno de este else dentro del if anterior.

Espero que te haya servido
  #3 (permalink)  
Antiguo 19/10/2010, 03:33
 
Fecha de Ingreso: octubre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: problema con privacy

muchisimas gracias si me pasaba eso :D

Etiquetas: privacy
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:48.