1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2025-07-12 04:39:23 +00:00

du refactor

This commit is contained in:
Amalvy Arthur
2018-06-21 16:15:33 +02:00
parent f066e22419
commit 92c784a76b
7 changed files with 41 additions and 13 deletions

View File

@ -16,13 +16,13 @@ void * runnable_Visitor(void * void_this){
Passenger * passenger = NEW(Passenger, (void*) this, VISITOR);
AGENT_OPTIONS;
this->passenger = (void*) passenger;
passenger->visitor = this;
printf("Bonjour, je suis %s et je souhaite rendre visite a %s\n", this->name, this->contact_name);
printf("Bip, %s appel a l'interphone\n%s habite a l'etage %d\n", this->name, this->contact_name, (this->destination = data->use_call_box(data, this->contact_name)));
data->main_building->go_to_floor(data->main_building, this->position, this->destination, passenger);
DELETE(passenger);
return NULL;
}
@ -31,6 +31,8 @@ void _free__Visitor(THIS(Visitor)){
free(this->name);
if (this->contact_name != NULL)
free(this->contact_name);
if (this->passenger != NULL)
free(this->passenger);
free(this);
}
@ -40,6 +42,7 @@ Visitor *_init_Visitor(int id, char* name, char * contact_name){
new_visitor->id = id;
new_visitor->position = 0;
new_visitor->destination = -1;
new_visitor->passenger = NULL;
if (contact_name != NULL)
new_visitor->contact_name = strdup(contact_name);

View File

@ -13,6 +13,7 @@ typedef struct o_Visitor {
PRIVATE char * contact_name;
PRIVATE int position;
PRIVATE int destination;
PRIVATE void * passenger;
PUBLIC void * (*runnable)(void* void_this);
PUBLIC char * (*get_name)(_THIS(Visitor));