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

Base du bâtiment

This commit is contained in:
2018-06-06 03:00:35 +02:00
parent 0fd63b47dd
commit 00eebf97f2
7 changed files with 74 additions and 1 deletions

View File

@ -2,3 +2,35 @@
// Created by Antoine Bartuccio on 05/06/2018.
//
#include "Building.h"
GETTER(Building, Elevator **, elevators)
void _free__Building(THIS(Building)){
int i = 0;
DELETE(this->residents);
DELETE(this->box);
for (i=0; i<ELEVATOR_NB; i++)
DELETE(this->elevators[i]);
free(this->elevators);
free(this);
}
Building *_init_Building(){
Building * new_building = malloc_or_die(sizeof(Building));
int i;
new_building->floors = FLOORS;
new_building->elevators = malloc_or_die(sizeof(Elevator*) * ELEVATOR_NB);
new_building->residents = NEW(List);
new_building->box = NEW(CommunicationBox);
for (i=0; i<ELEVATOR_NB; i++)
new_building->elevators[i] = NEW(Elevator);
LINK_ALL(Building, new_building,
get_elevators
)
return new_building;
}

View File

@ -6,6 +6,7 @@
#define LO41_BUILDING_H
#define ELEVATOR_NB 3
#define FLOORS 10
#include "../Objects.h"
#include "../List/List.h"
@ -16,8 +17,13 @@ typedef struct o_Building {
int floors;
List * residents;
CommunicationBox * box;
Elevator elevators[ELEVATOR_NB];
Elevator ** elevators;
SYNCHRONIZE Elevator ** (*get_elevators)(_THIS(Building));
DESTRUCTOR(Building);
} Building;
Building *_init_Building();
#endif //LO41_BUILDING_H