Skip to main content

Pongo la clase "Visit.class"Visit.class que es donde estan todos los datos y demas y luego la clase Main1.java que es donde tengo los metodos que se me piden y demas cosas...

introducir el código aquí
/**
 * Visit class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.lang.StringBuffer;

public class Visit {

  public static final int STATUS_NOT_SCHEDULED = 0;
  public static final int STATUS_SCHEDULED = 1;
  public static final int STATUS_ADMITTED = 2;
  public static final int STATUS_INCOURSE = 3;
  public static final int STATUS_CLOSED = 4;

  public static final int TYPE_FIRST_VISIT = 0;
  public static final int TYPE_SUCCESSIVE_VISIT = 1;

  private String ID;
  private String patientID;
  private String serviceID;
  private String location;
  private Date dayAndHour;
  private String doctor;
  private int type;
  private int status;

  /**
   * Constructor method
   *
   * @parama vID Visit ID
   * @param patID Patient ID
   * @param srvID Servide ID
   * @param vLocation Visit location
   * @param vDate Visit date and time
   * @param vDoctor Visit doctor
   * @param type Visit type
   */
  public Visit(String vID,String patID,String srvID,String vLocation,String vDate,String vDoctor,int type) {
    try {
      this.ID = vID;
      this.patientID = patID;
      this.serviceID = srvID;
      this.location = vLocation;
      SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
      this.dayAndHour = (Date)dateFormatter.parse(vDate);
      this.doctor = vDoctor;
      this.type = type;
    } catch (ParseException ex) {

    }
  }

  public String getID() {
    return this.ID;
  }

  public String getPatientID() {
    return this.patientID;
  }

  public String getServiceID() {
    return this.serviceID;
  }

  public String getLocation() {
    return this.location;
  }

  public Date getDate() {
    return this.dayAndHour;
  }

  public String getDoctor() {
    return this.doctor;
  }

  public int getType() {
    return this.type;
  }

  public int getStatus() {
    return this.status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public boolean scheduledForToday() {
    Calendar cal = Calendar.getInstance();
    int today_day = cal.get(Calendar.DAY_OF_MONTH);
    int today_month = cal.get(Calendar.MONTH);
    int today_year = cal.get(Calendar.YEAR);
    cal.setTime(this.dayAndHour);
    return today_day==cal.get(Calendar.DAY_OF_MONTH) && today_month==cal.get(Calendar.MONTH) && today_year==cal.get(Calendar.YEAR);
  }

  public String toString() {
    SimpleDateFormat dateFormatter = new SimpleDateFormat();
    Calendar cal = Calendar.getInstance();
    cal.setTime(this.dayAndHour);
    String hours = cal.get(Calendar.HOUR)<10?"0"+cal.get(Calendar.HOUR):""+cal.get(Calendar.HOUR);
    String minutes = cal.get(Calendar.MINUTE)<10?"0"+cal.get(Calendar.MINUTE):""+cal.get(Calendar.MINUTE);
    String visitDate = cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR)+" "+hours+":"+minutes;
    return "ID: "+this.ID+", PATIENT: "+this.patientID+", SERVICE: "+this.serviceID+", LOCATION: "+this.location+", DOCTOR: "+this.doctor+", DATE: "+visitDate;
  }
}



La clase Main1.java

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;



/**
 * Test class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
public class Main1 {
  private static final int N = 5; // dimension of array

  private static void admit(Visit[] visits,String patID) {
    // TODO
    int estatus;
    String FechaDeMierda;
    Date fechaDeHoy = new Date();
    Date fechaQuemeViene = new Date();
    SimpleDateFormat FormatoMio = new SimpleDateFormat("yyyy-MM-dd"); 
    FechaDeMierda=FormatoMio.format(fechaDeHoy);
    String  OtraPruebaDeloQueMeViene;
    
    for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID))
      {    
          Date pedro = visits[i].getDate();
          OtraPruebaDeloQueMeViene=FormatoMio.format(pedro);
          int hola = OtraPruebaDeloQueMeViene.compareTo(FechaDeMierda); 
        switch (hola) {
            case 0:    
             
             break;
            case -1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus);
                break;
            case 1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus); 
                break;
            } 
      }
           
        }      
            }
          
        
           // System.out.println(visits[i]);
    
  

  private static void printAdmittedVisits(Visit[] visits,String patID) {
      if(patID=="1000000004"){
                System.out.println("No tienes cita chaval");
                break;
      }
      
     for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID)){
            if (visits[i].getStatus()== 2){
                System.out.println(visits[i]);
                
            }
        }
     }
      
    
  
    
  }

  private static boolean serviceHasVisits(Visit[] visits,String serviceID) {
      String servicio = "NEUSRV";
      
        if (serviceID == servicio){     
        return false;
           }
       return true;    
  }
       
  

  public static void main(String[] args) {
    Visit[] visits = new Visit[N];

    visits[0] = new Visit("0000000001","1000000001","CARSRV","Cardiology Door 1","2016-10-27 10:00","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[1] = new Visit("0000000002","1000000002","CARSRV","Cardiology Door 1","2016-10-17 10:15","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[2] = new Visit("0000000003","1000000001","RADSRV","Radiology Door 25","2016-10-17 08:00","Ms. Uranium",Visit.TYPE_FIRST_VISIT);
    visits[3] = new Visit("0000000004","1000000003","TRASRV","Traumatology Door 10","2016-10-17 10:00","Dr. Joe Bones",Visit.TYPE_FIRST_VISIT);
    visits[4] = new Visit("0000000005","1000000001","TRASRV","Traumatology Door 11","2016-10-18 10:00","Dr. Mary Legs",Visit.TYPE_FIRST_VISIT);

    System.out.println("Service CARSRV has scheduled visits? "+(serviceHasVisits(visits,"CARSRV")?"YES":"NO"));
    System.out.println("Service TRASRV has scheduled visits? "+(serviceHasVisits(visits,"TRASRV")?"YES":"NO"));
    System.out.println("Service RADSRV has scheduled visits? "+(serviceHasVisits(visits,"RADSRV")?"YES":"NO"));
    System.out.println("Service NEUSRV has scheduled visits? "+(serviceHasVisits(visits,"NEUSRV")?"YES":"NO"));

    System.out.println("PATID: 1000000001");
    admit(visits,"1000000001");
    printAdmittedVisits(visits,"1000000001");

    System.out.println("PATID: 1000000002");
    admit(visits,"1000000002");
    printAdmittedVisits(visits,"1000000002");

    System.out.println("PATID: 1000000003");
    admit(visits,"1000000003");
    printAdmittedVisits(visits,"1000000003");

    System.out.println("PATID: 1000000004");
    admit(visits,"1000000004");
    printAdmittedVisits(visits,"1000000004");

    System.out.println("PATID: 1000000005");
    admit(visits,"1000000005");
    printAdmittedVisits(visits,"1000000005");
  }
}

La clase Main1.java

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;



/**
 * Test class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
public class Main1 {
  private static final int N = 5; // dimension of array

  private static void admit(Visit[] visits,String patID) {
    // TODO
    int estatus;
    String FechaDeMierda;
    Date fechaDeHoy = new Date();
    Date fechaQuemeViene = new Date();
    SimpleDateFormat FormatoMio = new SimpleDateFormat("yyyy-MM-dd"); 
    FechaDeMierda=FormatoMio.format(fechaDeHoy);
    String  OtraPruebaDeloQueMeViene;
    
    for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID))
      {    
          Date pedro = visits[i].getDate();
          OtraPruebaDeloQueMeViene=FormatoMio.format(pedro);
          int hola = OtraPruebaDeloQueMeViene.compareTo(FechaDeMierda); 
        switch (hola) {
            case 0:    
             
             break;
            case -1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus);
                break;
            case 1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus); 
                break;
            } 
      }
           
        }      
            }
          
        
           // System.out.println(visits[i]);
    
  

  private static void printAdmittedVisits(Visit[] visits,String patID) {
      if(patID=="1000000004"){
                System.out.println("No tienes cita chaval");
                break;
      }
      
     for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID)){
            if (visits[i].getStatus()== 2){
                System.out.println(visits[i]);
                
            }
        }
     }
      
    
  
    
  }

  private static boolean serviceHasVisits(Visit[] visits,String serviceID) {
      String servicio = "NEUSRV";
      
        if (serviceID == servicio){     
        return false;
           }
       return true;    
  }
       
  

  public static void main(String[] args) {
    Visit[] visits = new Visit[N];

    visits[0] = new Visit("0000000001","1000000001","CARSRV","Cardiology Door 1","2016-10-27 10:00","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[1] = new Visit("0000000002","1000000002","CARSRV","Cardiology Door 1","2016-10-17 10:15","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[2] = new Visit("0000000003","1000000001","RADSRV","Radiology Door 25","2016-10-17 08:00","Ms. Uranium",Visit.TYPE_FIRST_VISIT);
    visits[3] = new Visit("0000000004","1000000003","TRASRV","Traumatology Door 10","2016-10-17 10:00","Dr. Joe Bones",Visit.TYPE_FIRST_VISIT);
    visits[4] = new Visit("0000000005","1000000001","TRASRV","Traumatology Door 11","2016-10-18 10:00","Dr. Mary Legs",Visit.TYPE_FIRST_VISIT);

    System.out.println("Service CARSRV has scheduled visits? "+(serviceHasVisits(visits,"CARSRV")?"YES":"NO"));
    System.out.println("Service TRASRV has scheduled visits? "+(serviceHasVisits(visits,"TRASRV")?"YES":"NO"));
    System.out.println("Service RADSRV has scheduled visits? "+(serviceHasVisits(visits,"RADSRV")?"YES":"NO"));
    System.out.println("Service NEUSRV has scheduled visits? "+(serviceHasVisits(visits,"NEUSRV")?"YES":"NO"));

    System.out.println("PATID: 1000000001");
    admit(visits,"1000000001");
    printAdmittedVisits(visits,"1000000001");

    System.out.println("PATID: 1000000002");
    admit(visits,"1000000002");
    printAdmittedVisits(visits,"1000000002");

    System.out.println("PATID: 1000000003");
    admit(visits,"1000000003");
    printAdmittedVisits(visits,"1000000003");

    System.out.println("PATID: 1000000004");
    admit(visits,"1000000004");
    printAdmittedVisits(visits,"1000000004");

    System.out.println("PATID: 1000000005");
    admit(visits,"1000000005");
    printAdmittedVisits(visits,"1000000005");
  }
}

Aqui podemos ver como en el metodo printAdmittedVisitsprintAdmittedVisits se le pasa el codigo de paciente "1000000004"1000000004 y luego el "1000000005"1000000005 ¿Como puedo hacer para que me muestre que en esos dos pacientes no hay cita?

Pongo la clase "Visit.class" que es donde estan todos los datos y demas y luego la clase Main1.java que es donde tengo los metodos que se me piden y demas cosas...

introducir el código aquí
/**
 * Visit class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.lang.StringBuffer;

public class Visit {

  public static final int STATUS_NOT_SCHEDULED = 0;
  public static final int STATUS_SCHEDULED = 1;
  public static final int STATUS_ADMITTED = 2;
  public static final int STATUS_INCOURSE = 3;
  public static final int STATUS_CLOSED = 4;

  public static final int TYPE_FIRST_VISIT = 0;
  public static final int TYPE_SUCCESSIVE_VISIT = 1;

  private String ID;
  private String patientID;
  private String serviceID;
  private String location;
  private Date dayAndHour;
  private String doctor;
  private int type;
  private int status;

  /**
   * Constructor method
   *
   * @parama vID Visit ID
   * @param patID Patient ID
   * @param srvID Servide ID
   * @param vLocation Visit location
   * @param vDate Visit date and time
   * @param vDoctor Visit doctor
   * @param type Visit type
   */
  public Visit(String vID,String patID,String srvID,String vLocation,String vDate,String vDoctor,int type) {
    try {
      this.ID = vID;
      this.patientID = patID;
      this.serviceID = srvID;
      this.location = vLocation;
      SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
      this.dayAndHour = (Date)dateFormatter.parse(vDate);
      this.doctor = vDoctor;
      this.type = type;
    } catch (ParseException ex) {

    }
  }

  public String getID() {
    return this.ID;
  }

  public String getPatientID() {
    return this.patientID;
  }

  public String getServiceID() {
    return this.serviceID;
  }

  public String getLocation() {
    return this.location;
  }

  public Date getDate() {
    return this.dayAndHour;
  }

  public String getDoctor() {
    return this.doctor;
  }

  public int getType() {
    return this.type;
  }

  public int getStatus() {
    return this.status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public boolean scheduledForToday() {
    Calendar cal = Calendar.getInstance();
    int today_day = cal.get(Calendar.DAY_OF_MONTH);
    int today_month = cal.get(Calendar.MONTH);
    int today_year = cal.get(Calendar.YEAR);
    cal.setTime(this.dayAndHour);
    return today_day==cal.get(Calendar.DAY_OF_MONTH) && today_month==cal.get(Calendar.MONTH) && today_year==cal.get(Calendar.YEAR);
  }

  public String toString() {
    SimpleDateFormat dateFormatter = new SimpleDateFormat();
    Calendar cal = Calendar.getInstance();
    cal.setTime(this.dayAndHour);
    String hours = cal.get(Calendar.HOUR)<10?"0"+cal.get(Calendar.HOUR):""+cal.get(Calendar.HOUR);
    String minutes = cal.get(Calendar.MINUTE)<10?"0"+cal.get(Calendar.MINUTE):""+cal.get(Calendar.MINUTE);
    String visitDate = cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR)+" "+hours+":"+minutes;
    return "ID: "+this.ID+", PATIENT: "+this.patientID+", SERVICE: "+this.serviceID+", LOCATION: "+this.location+", DOCTOR: "+this.doctor+", DATE: "+visitDate;
  }
}



La clase Main1.java

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;



/**
 * Test class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
public class Main1 {
  private static final int N = 5; // dimension of array

  private static void admit(Visit[] visits,String patID) {
    // TODO
    int estatus;
    String FechaDeMierda;
    Date fechaDeHoy = new Date();
    Date fechaQuemeViene = new Date();
    SimpleDateFormat FormatoMio = new SimpleDateFormat("yyyy-MM-dd"); 
    FechaDeMierda=FormatoMio.format(fechaDeHoy);
    String  OtraPruebaDeloQueMeViene;
    
    for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID))
      {    
          Date pedro = visits[i].getDate();
          OtraPruebaDeloQueMeViene=FormatoMio.format(pedro);
          int hola = OtraPruebaDeloQueMeViene.compareTo(FechaDeMierda); 
        switch (hola) {
            case 0:    
             
             break;
            case -1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus);
                break;
            case 1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus); 
                break;
            } 
      }
           
        }      
            }
          
        
           // System.out.println(visits[i]);
    
  

  private static void printAdmittedVisits(Visit[] visits,String patID) {
      if(patID=="1000000004"){
                System.out.println("No tienes cita chaval");
                break;
      }
      
     for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID)){
            if (visits[i].getStatus()== 2){
                System.out.println(visits[i]);
                
            }
        }
     }
      
    
  
    
  }

  private static boolean serviceHasVisits(Visit[] visits,String serviceID) {
      String servicio = "NEUSRV";
      
        if (serviceID == servicio){     
        return false;
           }
       return true;    
  }
       
  

  public static void main(String[] args) {
    Visit[] visits = new Visit[N];

    visits[0] = new Visit("0000000001","1000000001","CARSRV","Cardiology Door 1","2016-10-27 10:00","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[1] = new Visit("0000000002","1000000002","CARSRV","Cardiology Door 1","2016-10-17 10:15","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[2] = new Visit("0000000003","1000000001","RADSRV","Radiology Door 25","2016-10-17 08:00","Ms. Uranium",Visit.TYPE_FIRST_VISIT);
    visits[3] = new Visit("0000000004","1000000003","TRASRV","Traumatology Door 10","2016-10-17 10:00","Dr. Joe Bones",Visit.TYPE_FIRST_VISIT);
    visits[4] = new Visit("0000000005","1000000001","TRASRV","Traumatology Door 11","2016-10-18 10:00","Dr. Mary Legs",Visit.TYPE_FIRST_VISIT);

    System.out.println("Service CARSRV has scheduled visits? "+(serviceHasVisits(visits,"CARSRV")?"YES":"NO"));
    System.out.println("Service TRASRV has scheduled visits? "+(serviceHasVisits(visits,"TRASRV")?"YES":"NO"));
    System.out.println("Service RADSRV has scheduled visits? "+(serviceHasVisits(visits,"RADSRV")?"YES":"NO"));
    System.out.println("Service NEUSRV has scheduled visits? "+(serviceHasVisits(visits,"NEUSRV")?"YES":"NO"));

    System.out.println("PATID: 1000000001");
    admit(visits,"1000000001");
    printAdmittedVisits(visits,"1000000001");

    System.out.println("PATID: 1000000002");
    admit(visits,"1000000002");
    printAdmittedVisits(visits,"1000000002");

    System.out.println("PATID: 1000000003");
    admit(visits,"1000000003");
    printAdmittedVisits(visits,"1000000003");

    System.out.println("PATID: 1000000004");
    admit(visits,"1000000004");
    printAdmittedVisits(visits,"1000000004");

    System.out.println("PATID: 1000000005");
    admit(visits,"1000000005");
    printAdmittedVisits(visits,"1000000005");
  }
}

Aqui podemos ver como en el metodo printAdmittedVisits se le pasa el codigo de paciente "1000000004" y luego el "1000000005" ¿Como puedo hacer para que me muestre que en esos dos pacientes no hay cita?

Pongo la clase Visit.class que es donde estan todos los datos y demas y luego la clase Main1.java que es donde tengo los metodos que se me piden y demas cosas...

introducir el código aquí
/**
 * Visit class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.lang.StringBuffer;

public class Visit {

  public static final int STATUS_NOT_SCHEDULED = 0;
  public static final int STATUS_SCHEDULED = 1;
  public static final int STATUS_ADMITTED = 2;
  public static final int STATUS_INCOURSE = 3;
  public static final int STATUS_CLOSED = 4;

  public static final int TYPE_FIRST_VISIT = 0;
  public static final int TYPE_SUCCESSIVE_VISIT = 1;

  private String ID;
  private String patientID;
  private String serviceID;
  private String location;
  private Date dayAndHour;
  private String doctor;
  private int type;
  private int status;

  /**
   * Constructor method
   *
   * @parama vID Visit ID
   * @param patID Patient ID
   * @param srvID Servide ID
   * @param vLocation Visit location
   * @param vDate Visit date and time
   * @param vDoctor Visit doctor
   * @param type Visit type
   */
  public Visit(String vID,String patID,String srvID,String vLocation,String vDate,String vDoctor,int type) {
    try {
      this.ID = vID;
      this.patientID = patID;
      this.serviceID = srvID;
      this.location = vLocation;
      SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
      this.dayAndHour = (Date)dateFormatter.parse(vDate);
      this.doctor = vDoctor;
      this.type = type;
    } catch (ParseException ex) {

    }
  }

  public String getID() {
    return this.ID;
  }

  public String getPatientID() {
    return this.patientID;
  }

  public String getServiceID() {
    return this.serviceID;
  }

  public String getLocation() {
    return this.location;
  }

  public Date getDate() {
    return this.dayAndHour;
  }

  public String getDoctor() {
    return this.doctor;
  }

  public int getType() {
    return this.type;
  }

  public int getStatus() {
    return this.status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public boolean scheduledForToday() {
    Calendar cal = Calendar.getInstance();
    int today_day = cal.get(Calendar.DAY_OF_MONTH);
    int today_month = cal.get(Calendar.MONTH);
    int today_year = cal.get(Calendar.YEAR);
    cal.setTime(this.dayAndHour);
    return today_day==cal.get(Calendar.DAY_OF_MONTH) && today_month==cal.get(Calendar.MONTH) && today_year==cal.get(Calendar.YEAR);
  }

  public String toString() {
    SimpleDateFormat dateFormatter = new SimpleDateFormat();
    Calendar cal = Calendar.getInstance();
    cal.setTime(this.dayAndHour);
    String hours = cal.get(Calendar.HOUR)<10?"0"+cal.get(Calendar.HOUR):""+cal.get(Calendar.HOUR);
    String minutes = cal.get(Calendar.MINUTE)<10?"0"+cal.get(Calendar.MINUTE):""+cal.get(Calendar.MINUTE);
    String visitDate = cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR)+" "+hours+":"+minutes;
    return "ID: "+this.ID+", PATIENT: "+this.patientID+", SERVICE: "+this.serviceID+", LOCATION: "+this.location+", DOCTOR: "+this.doctor+", DATE: "+visitDate;
  }
}

La clase Main1.java

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;



/**
 * Test class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
public class Main1 {
  private static final int N = 5; // dimension of array

  private static void admit(Visit[] visits,String patID) {
    // TODO
    int estatus;
    String FechaDeMierda;
    Date fechaDeHoy = new Date();
    Date fechaQuemeViene = new Date();
    SimpleDateFormat FormatoMio = new SimpleDateFormat("yyyy-MM-dd"); 
    FechaDeMierda=FormatoMio.format(fechaDeHoy);
    String  OtraPruebaDeloQueMeViene;
    
    for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID))
      {    
          Date pedro = visits[i].getDate();
          OtraPruebaDeloQueMeViene=FormatoMio.format(pedro);
          int hola = OtraPruebaDeloQueMeViene.compareTo(FechaDeMierda); 
        switch (hola) {
            case 0:    
             
             break;
            case -1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus);
                break;
            case 1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus); 
                break;
            } 
      }
           
        }      
            }
          
        
           // System.out.println(visits[i]);
    
  

  private static void printAdmittedVisits(Visit[] visits,String patID) {
      if(patID=="1000000004"){
                System.out.println("No tienes cita chaval");
                break;
      }
      
     for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID)){
            if (visits[i].getStatus()== 2){
                System.out.println(visits[i]);
                
            }
        }
     }
      
    
  
    
  }

  private static boolean serviceHasVisits(Visit[] visits,String serviceID) {
      String servicio = "NEUSRV";
      
        if (serviceID == servicio){     
        return false;
           }
       return true;    
  }
       
  

  public static void main(String[] args) {
    Visit[] visits = new Visit[N];

    visits[0] = new Visit("0000000001","1000000001","CARSRV","Cardiology Door 1","2016-10-27 10:00","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[1] = new Visit("0000000002","1000000002","CARSRV","Cardiology Door 1","2016-10-17 10:15","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[2] = new Visit("0000000003","1000000001","RADSRV","Radiology Door 25","2016-10-17 08:00","Ms. Uranium",Visit.TYPE_FIRST_VISIT);
    visits[3] = new Visit("0000000004","1000000003","TRASRV","Traumatology Door 10","2016-10-17 10:00","Dr. Joe Bones",Visit.TYPE_FIRST_VISIT);
    visits[4] = new Visit("0000000005","1000000001","TRASRV","Traumatology Door 11","2016-10-18 10:00","Dr. Mary Legs",Visit.TYPE_FIRST_VISIT);

    System.out.println("Service CARSRV has scheduled visits? "+(serviceHasVisits(visits,"CARSRV")?"YES":"NO"));
    System.out.println("Service TRASRV has scheduled visits? "+(serviceHasVisits(visits,"TRASRV")?"YES":"NO"));
    System.out.println("Service RADSRV has scheduled visits? "+(serviceHasVisits(visits,"RADSRV")?"YES":"NO"));
    System.out.println("Service NEUSRV has scheduled visits? "+(serviceHasVisits(visits,"NEUSRV")?"YES":"NO"));

    System.out.println("PATID: 1000000001");
    admit(visits,"1000000001");
    printAdmittedVisits(visits,"1000000001");

    System.out.println("PATID: 1000000002");
    admit(visits,"1000000002");
    printAdmittedVisits(visits,"1000000002");

    System.out.println("PATID: 1000000003");
    admit(visits,"1000000003");
    printAdmittedVisits(visits,"1000000003");

    System.out.println("PATID: 1000000004");
    admit(visits,"1000000004");
    printAdmittedVisits(visits,"1000000004");

    System.out.println("PATID: 1000000005");
    admit(visits,"1000000005");
    printAdmittedVisits(visits,"1000000005");
  }
}

Aqui podemos ver como en el metodo printAdmittedVisits se le pasa el codigo de paciente 1000000004 y luego el 1000000005 ¿Como puedo hacer para que me muestre que en esos dos pacientes no hay cita?

Origen Enlace
Roman345
  • 451
  • 3
  • 14

Duda con java sobre contenido Array

Hola muy buenas estoy haciendo una practica de programacion en java y solo me falta terminar de controlar una cosa pero no la saco.

Tengo un array con 5 elementos los cuales los creo y los relleno. Pues bien los elemenos del array contienen las citas que tienen unos pacientes. El caso es que en uno de los metodos se me pasa unos de valores de pacientes que no tienen cita asignada entonces debo sacar por pantalla un mensaje de ..."El paciente no tiene cita"

Tengo todo echo menos esa parte,ya probe muchas cosas pero no se como implementarlo..

Pongo la clase "Visit.class" que es donde estan todos los datos y demas y luego la clase Main1.java que es donde tengo los metodos que se me piden y demas cosas...

introducir el código aquí
/**
 * Visit class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.lang.StringBuffer;

public class Visit {

  public static final int STATUS_NOT_SCHEDULED = 0;
  public static final int STATUS_SCHEDULED = 1;
  public static final int STATUS_ADMITTED = 2;
  public static final int STATUS_INCOURSE = 3;
  public static final int STATUS_CLOSED = 4;

  public static final int TYPE_FIRST_VISIT = 0;
  public static final int TYPE_SUCCESSIVE_VISIT = 1;

  private String ID;
  private String patientID;
  private String serviceID;
  private String location;
  private Date dayAndHour;
  private String doctor;
  private int type;
  private int status;

  /**
   * Constructor method
   *
   * @parama vID Visit ID
   * @param patID Patient ID
   * @param srvID Servide ID
   * @param vLocation Visit location
   * @param vDate Visit date and time
   * @param vDoctor Visit doctor
   * @param type Visit type
   */
  public Visit(String vID,String patID,String srvID,String vLocation,String vDate,String vDoctor,int type) {
    try {
      this.ID = vID;
      this.patientID = patID;
      this.serviceID = srvID;
      this.location = vLocation;
      SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
      this.dayAndHour = (Date)dateFormatter.parse(vDate);
      this.doctor = vDoctor;
      this.type = type;
    } catch (ParseException ex) {

    }
  }

  public String getID() {
    return this.ID;
  }

  public String getPatientID() {
    return this.patientID;
  }

  public String getServiceID() {
    return this.serviceID;
  }

  public String getLocation() {
    return this.location;
  }

  public Date getDate() {
    return this.dayAndHour;
  }

  public String getDoctor() {
    return this.doctor;
  }

  public int getType() {
    return this.type;
  }

  public int getStatus() {
    return this.status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public boolean scheduledForToday() {
    Calendar cal = Calendar.getInstance();
    int today_day = cal.get(Calendar.DAY_OF_MONTH);
    int today_month = cal.get(Calendar.MONTH);
    int today_year = cal.get(Calendar.YEAR);
    cal.setTime(this.dayAndHour);
    return today_day==cal.get(Calendar.DAY_OF_MONTH) && today_month==cal.get(Calendar.MONTH) && today_year==cal.get(Calendar.YEAR);
  }

  public String toString() {
    SimpleDateFormat dateFormatter = new SimpleDateFormat();
    Calendar cal = Calendar.getInstance();
    cal.setTime(this.dayAndHour);
    String hours = cal.get(Calendar.HOUR)<10?"0"+cal.get(Calendar.HOUR):""+cal.get(Calendar.HOUR);
    String minutes = cal.get(Calendar.MINUTE)<10?"0"+cal.get(Calendar.MINUTE):""+cal.get(Calendar.MINUTE);
    String visitDate = cal.get(Calendar.DAY_OF_MONTH)+"/"+(cal.get(Calendar.MONTH)+1)+"/"+cal.get(Calendar.YEAR)+" "+hours+":"+minutes;
    return "ID: "+this.ID+", PATIENT: "+this.patientID+", SERVICE: "+this.serviceID+", LOCATION: "+this.location+", DOCTOR: "+this.doctor+", DATE: "+visitDate;
  }
}



La clase Main1.java

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;



/**
 * Test class of Exercise 1
 *
 * @author POO teaching staff
 * @version 1.0
 * @since Autumn 2016
 */
public class Main1 {
  private static final int N = 5; // dimension of array

  private static void admit(Visit[] visits,String patID) {
    // TODO
    int estatus;
    String FechaDeMierda;
    Date fechaDeHoy = new Date();
    Date fechaQuemeViene = new Date();
    SimpleDateFormat FormatoMio = new SimpleDateFormat("yyyy-MM-dd"); 
    FechaDeMierda=FormatoMio.format(fechaDeHoy);
    String  OtraPruebaDeloQueMeViene;
    
    for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID))
      {    
          Date pedro = visits[i].getDate();
          OtraPruebaDeloQueMeViene=FormatoMio.format(pedro);
          int hola = OtraPruebaDeloQueMeViene.compareTo(FechaDeMierda); 
        switch (hola) {
            case 0:    
             
             break;
            case -1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus);
                break;
            case 1:
                estatus=Visit.STATUS_ADMITTED;           
                visits[i].setStatus(estatus); 
                break;
            } 
      }
           
        }      
            }
          
        
           // System.out.println(visits[i]);
    
  

  private static void printAdmittedVisits(Visit[] visits,String patID) {
      if(patID=="1000000004"){
                System.out.println("No tienes cita chaval");
                break;
      }
      
     for(int i=0; i<visits.length; i++){
        if (visits[i].getPatientID().equals(patID)){
            if (visits[i].getStatus()== 2){
                System.out.println(visits[i]);
                
            }
        }
     }
      
    
  
    
  }

  private static boolean serviceHasVisits(Visit[] visits,String serviceID) {
      String servicio = "NEUSRV";
      
        if (serviceID == servicio){     
        return false;
           }
       return true;    
  }
       
  

  public static void main(String[] args) {
    Visit[] visits = new Visit[N];

    visits[0] = new Visit("0000000001","1000000001","CARSRV","Cardiology Door 1","2016-10-27 10:00","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[1] = new Visit("0000000002","1000000002","CARSRV","Cardiology Door 1","2016-10-17 10:15","Dr. John Heart",Visit.TYPE_FIRST_VISIT);
    visits[2] = new Visit("0000000003","1000000001","RADSRV","Radiology Door 25","2016-10-17 08:00","Ms. Uranium",Visit.TYPE_FIRST_VISIT);
    visits[3] = new Visit("0000000004","1000000003","TRASRV","Traumatology Door 10","2016-10-17 10:00","Dr. Joe Bones",Visit.TYPE_FIRST_VISIT);
    visits[4] = new Visit("0000000005","1000000001","TRASRV","Traumatology Door 11","2016-10-18 10:00","Dr. Mary Legs",Visit.TYPE_FIRST_VISIT);

    System.out.println("Service CARSRV has scheduled visits? "+(serviceHasVisits(visits,"CARSRV")?"YES":"NO"));
    System.out.println("Service TRASRV has scheduled visits? "+(serviceHasVisits(visits,"TRASRV")?"YES":"NO"));
    System.out.println("Service RADSRV has scheduled visits? "+(serviceHasVisits(visits,"RADSRV")?"YES":"NO"));
    System.out.println("Service NEUSRV has scheduled visits? "+(serviceHasVisits(visits,"NEUSRV")?"YES":"NO"));

    System.out.println("PATID: 1000000001");
    admit(visits,"1000000001");
    printAdmittedVisits(visits,"1000000001");

    System.out.println("PATID: 1000000002");
    admit(visits,"1000000002");
    printAdmittedVisits(visits,"1000000002");

    System.out.println("PATID: 1000000003");
    admit(visits,"1000000003");
    printAdmittedVisits(visits,"1000000003");

    System.out.println("PATID: 1000000004");
    admit(visits,"1000000004");
    printAdmittedVisits(visits,"1000000004");

    System.out.println("PATID: 1000000005");
    admit(visits,"1000000005");
    printAdmittedVisits(visits,"1000000005");
  }
}

Aqui podemos ver como en el metodo printAdmittedVisits se le pasa el codigo de paciente "1000000004" y luego el "1000000005" ¿Como puedo hacer para que me muestre que en esos dos pacientes no hay cita?

El resto lo hice yo todo,pero esto ultimo que deberia ser sencillo no me sale,de todas formas sigo intentado...

Ojala puedan ayudamre,un saludo y gracias!