1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2025-07-12 20:59:24 +00:00

La structure du projet avance, on peut maintenant charger les résidents et les visiteurs

This commit is contained in:
2018-06-06 20:29:02 +02:00
parent 8b29c54d76
commit 8ed34b4593
14 changed files with 268 additions and 8 deletions

34
Resident/Resident.c Normal file
View File

@ -0,0 +1,34 @@
//
// 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));
new_resident->name = malloc_or_die(sizeof(char) * strlen(name));
strcpy(new_resident->name, name);
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;
}

28
Resident/Resident.h Normal file
View File

@ -0,0 +1,28 @@
//
// Created by Antoine Bartuccio on 06/06/2018.
//
#ifndef LO41_RESIDENT_H
#define LO41_RESIDENT_H
#include "../Objects.h"
typedef struct o_Resident {
PRIVATE int id;
PRIVATE int apartment_floor;
PRIVATE int destination;
PRIVATE int position;
PRIVATE char* name;
PUBLIC char * (*get_name)(_THIS(Resident));
PUBLIC int (*get_id)(_THIS(Resident));
PUBLIC int (*get_apartment_floor)(_THIS(Resident));
DESTRUCTOR(Resident);
} Resident;
FRIENDLY(name, Building)
Resident *_init_Resident(int id, char * name, int apartment_floor);
#endif //LO41_RESIDENT_H