problemas con agregar a una cola de prioridad
Publicado por Ricardo (2 intervenciones) el 06/09/2014 14:56:23
Buenas , estoy intentando agregar unos datos de una clase a una cola de prioridad declarada en otra , el caso es que no me permite agregar mas de 1 elemento , ya que la segunda vez que intento agregar un elemento este
me salta al hilo, os dejo el codigo , darme ideas porfa
public class Agenda {
me salta al hilo, os dejo el codigo , darme ideas porfa
public class Agenda {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Do stuff with the user
//Do stuff with user
//Do stuff with user
////////////////////////////// ATRIBUTOS //////////////////////////////
//LISTA DE PRIORIDAD
PriorityQueue<Tarea> colaTareas;
//ARRAY DE OBJETOS
//private ArrayList<Tarea> colaTareas;
////////////////////////////// CONSTRUCTORES //////////////////////////////
public Agenda(){
colaTareas = new PriorityQueue<Tarea>();
//ARRAY DE OBJETOS
//colaTareas= new ArrayList<>();
}
////////////////////////////// MÉTODOS PÚBLICOS //////////////////////////////
/* public Tarea addTimeToFirst( int seconds ){
Tarea first = colaTareas.poll();
if ( first != null ){
first.retrasar( seconds );
colaTareas.add( first );
}
return getFirst();
}*/
public void addTarea(String tareaName, String date, String hour) throws FechaException {
Calendar today = Calendar.getInstance();
String other = date+" "+hour;
Calendar otherday = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
//HAY QUE SACAR UNA ECEPCIóN
try {
otherday.setTime( sdf.parse(other) );
} catch (ParseException e) {
//throw new FechaException( tareaName, date, hour );
}
if (today.compareTo(otherday)<0){
Calendar newCalendar2 = Calendar.getInstance();
//ARRAY DE OBJETOS
//colaTareas.add( newTarea );
//LISTA DE PRIORIDAD
Tarea newTarea = new Tarea(tareaName);
colaTareas.offer(newTarea);
}else{
// throw new FechaException( tareaName, date, hour );
//Escepcion que pasa de mi culo!!!!!!!!!!!!!!!!!!!!!!
throw new FechaException("Números fuera del intervalo");
}
}
Valora esta pregunta


0