2018-06-06 18:29:02 +00:00
|
|
|
//
|
|
|
|
// Created by Antoine Bartuccio on 06/06/2018.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "Resident.h"
|
|
|
|
|
|
|
|
GETTER(Resident, char *, name);
|
|
|
|
GETTER(Resident, int, id);
|
|
|
|
GETTER(Resident, int, apartment_floor);
|
|
|
|
|
|
|
|
void _free__Resident(THIS(Resident)){
|
|
|
|
if (this->name != NULL)
|
|
|
|
free(this->name);
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Resident *_init_Resident(int id, char* name, int apartment_floor){
|
|
|
|
Resident * new_resident = malloc_or_die(sizeof(Resident));
|
2018-06-06 18:33:34 +00:00
|
|
|
new_resident->name = strdup(name);
|
2018-06-06 18:29:02 +00:00
|
|
|
new_resident->id = id;
|
|
|
|
new_resident->apartment_floor = apartment_floor;
|
|
|
|
new_resident->position = new_resident->apartment_floor;
|
|
|
|
new_resident->destination = -1;
|
|
|
|
|
|
|
|
LINK_ALL(Resident, new_resident,
|
|
|
|
get_name,
|
|
|
|
get_id,
|
|
|
|
get_apartment_floor
|
|
|
|
)
|
|
|
|
|
|
|
|
return new_resident;
|
|
|
|
}
|