mirror of
https://gitlab.com/klmp200/LO41.git
synced 2025-07-12 04:39:23 +00:00
du refactor
This commit is contained in:
@ -19,19 +19,21 @@ void * runnable_Resident(void * void_this){
|
||||
|
||||
AGENT_OPTIONS;
|
||||
|
||||
this->passenger = passenger;
|
||||
passenger->resident = this;
|
||||
passenger->type = RESIDENT;
|
||||
|
||||
printf("Je suis le resident %s et je suis a l'etage %d en direction de l'etage %d\n",
|
||||
this->name, this->apartment_floor, this->destination);
|
||||
data->main_building->go_to_floor(data->main_building, this->position, this->destination, passenger);
|
||||
DELETE(passenger);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _free__Resident(THIS(Resident)){
|
||||
if (this->name != NULL)
|
||||
free(this->name);
|
||||
if(this->passenger != NULL)
|
||||
free(this->passenger);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@ -43,6 +45,7 @@ Resident *_init_Resident(int id, char* name, int apartment_floor, int destinatio
|
||||
new_resident->apartment_floor = apartment_floor;
|
||||
new_resident->position = new_resident->apartment_floor;
|
||||
new_resident->destination = destination;
|
||||
new_resident->passenger = NULL;
|
||||
|
||||
LINK_ALL(Resident, new_resident,
|
||||
get_name,
|
||||
|
@ -13,6 +13,7 @@ typedef struct o_Resident {
|
||||
PRIVATE int destination;
|
||||
PRIVATE int position;
|
||||
PRIVATE char* name;
|
||||
PRIVATE void* passenger;
|
||||
|
||||
PUBLIC void * (*runnable)(void * void_this);
|
||||
PUBLIC char * (*get_name)(_THIS(Resident));
|
||||
|
Reference in New Issue
Block a user