-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEmergencia2.java
More file actions
57 lines (52 loc) · 1.49 KB
/
Emergencia2.java
File metadata and controls
57 lines (52 loc) · 1.49 KB
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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;
// TODO: Auto-generated Javadoc
/**
* The Class Emergencia2.
*/
public class Emergencia2{
/** The pacientes. */
private Vector<Paciente> pacientes = new Vector<Paciente>();
/** The cant patients. */
private int cantPatients= 0;
/**
* Entrar pacientes.
*
* @param file the file
* @throws FileNotFoundException the file not found exception
*/
public void entrarPacientes(String file) throws FileNotFoundException{
File archivo = new File(file);
String palabra = "";
String[] palabras;
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
try {
while ((line = br.readLine()) != null) {
palabras=line.split(",");
pacientes.add(new Paciente(palabras[0].replace(" ", ""), palabras[1].replace(" ", ""),palabras[2].replace(" ", "")));
cantPatients+=1;
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Devolver pacientes en orden.
*
* @return the string
*/
public String devolverPacientesEnOrden(){
String pacientesEnOrden="";
VectorHeap2 heap = new VectorHeap2 (pacientes);
for(int i=0; i<cantPatients; i++){
Paciente paciente = (Paciente)heap.remove();
pacientesEnOrden=pacientesEnOrden+paciente.getNombrePaciente()+" "+","+paciente.getEnfermedad()+" "+","+paciente.getPrioridad()+"\n";
}
return pacientesEnOrden;
}
}