public class Kasse
{
private Praxis praxis;
private BinarySearchTree<Praxis> verwaltung;
private List<Patient> liste;
private DatabaseConnector con;
private QueryResult res;
private Patient temp;
public Kasse(){
verwaltung = new BinarySearchTree<Praxis>();
}
public void patientenEmpfangen(Praxis pPraxis){
verwaltung.insert(pPraxis);
}
public BinarySearchTree<Praxis> getBaum(){
return verwaltung;
}
public void speichern(List<Patient> pList){
con = new DatabaseConnector("",0,"Datenbank.db","","");
if(pList != null){
pList.toFirst();
while(pList.hasAccess()){
con.executeStatement("INSERT INTO Patienten (Name, Uhrzeit) VALUES ('" + pList.getContent().getName() + "'," + pList.getContent().getUhrzeit() +")");
pList.next();
}
con.close();
}
}
public List<Patient> wasTueIch(){
List<Patient> liste = new List<Patient>();
List<Patient> tempListe = new List<Patient>();
if(verwaltung != null){
hilfsMethode(verwaltung, liste);
}
if(liste != null){
liste.toFirst();
}
int check = 2359;
while(liste.hasAccess()){
while(liste.hasAccess()){
if(liste.getContent().getUhrzeit() < check){
temp = liste.getContent();
check = liste.getContent().getUhrzeit();
liste.next();
}
}
tempListe.append(temp);
liste.toFirst();
while(liste.getContent() != temp){
liste.next();
}
liste.remove();
liste.toFirst();
}
return tempListe;
}
public void hilfsMethode(BinarySearchTree<Praxis> pBaum, List<Patient> pList){
Queue<Patient> temp = pBaum.getContent().getPatientenschlange();
if(pBaum != null && pList != null){
while(!temp.isEmpty()){
pList.append(temp.front());
temp.dequeue();
}
if(!pBaum.getLeftTree().isEmpty()){
hilfsMethode(pBaum.getLeftTree(), pList);
}
if(!pBaum.getRightTree().isEmpty()){
hilfsMethode(pBaum.getRightTree(), pList);
}}
}
}