2022-02-10 16:44:22 +00:00
|
|
|
#include "deur.h"
|
|
|
|
#include <utility>
|
2022-03-29 16:38:53 +00:00
|
|
|
#include <iostream>
|
2022-02-10 16:44:22 +00:00
|
|
|
|
|
|
|
Deur::Deur(int x, int y, int lengte): x_coordinaat(x), y_coordinaat(y), lengte(lengte){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pair<int,int> Deur::coordinaten() const {
|
|
|
|
pair<int,int> temp;
|
|
|
|
temp.first=x_coordinaat;
|
|
|
|
temp.second=y_coordinaat;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Deur::open(){
|
2022-03-29 16:38:53 +00:00
|
|
|
if(!sloten.empty()){
|
|
|
|
for(std::list<Slot*>::iterator i = sloten.begin(); i != sloten.end(); ++i){
|
|
|
|
if (!(*i)->isVergrendeld()){
|
|
|
|
status = true;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
status = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else status = true;
|
2022-02-10 16:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Deur::sluit(){
|
|
|
|
status = false;
|
2022-03-29 16:38:53 +00:00
|
|
|
if(!sloten.empty()){
|
|
|
|
for(std::list<Slot*>::iterator i = sloten.begin(); i != sloten.end(); ++i){
|
|
|
|
(*i)->vergrendel();
|
|
|
|
}
|
|
|
|
}
|
2022-02-10 16:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Deur::isDeurOpen(){
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int Deur::deurLengte(){
|
|
|
|
return lengte;
|
|
|
|
}
|
2022-03-29 16:38:53 +00:00
|
|
|
|
|
|
|
void Deur::addSlot(Slot *s){
|
|
|
|
sloten.push_back(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
Slot* Deur::geefSleutel(int i){
|
|
|
|
std::list<Slot*>::iterator it = sloten.begin();
|
|
|
|
advance(it, i);
|
|
|
|
return *it;
|
|
|
|
}
|
2022-04-06 16:01:47 +00:00
|
|
|
|
|
|
|
std::list<Slot*> Deur::geefSlot(){
|
|
|
|
return sloten;
|
|
|
|
}
|