mirror of
https://gitlab.com/klmp200/LO41.git
synced 2025-07-12 04:39:23 +00:00
du refactor
This commit is contained in:
@ -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);
|
||||
|
@ -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));
|
||||
|
Reference in New Issue
Block a user