This commit is contained in:
2026-02-13 16:12:39 +01:00
parent 40e2167003
commit b646f5ca78
16 changed files with 984 additions and 33 deletions
@@ -0,0 +1,47 @@
#ifndef ANIMALS_H
#define ANIMALS_H
#include <stdio.h>
enum animal_type
{
INSECT,
FISH,
};
struct fish
{
char* species;
int swimming_speed;
size_t size;
int lives_in_fresh_water;
};
struct insect
{
char* species;
size_t size;
int can_fly;
int can_swim;
};
union animals
{
struct insect* insect;
struct fish* fish;
};
struct animal
{
enum animal_type type;
union animals animal;
char* color;
};
struct fish* fish_init(const char* species, int speed, size_t size, int fresh_water);
struct animal* animal_from_fish(const char* color, struct fish* fish);
void free_fish(struct fish* fish);
struct insect *insect_init(const char *species, size_t size, int can_fly, int can_swim);
struct animal* animal_from_insect(const char* color, struct insect* insect);
void free_insect(struct insect* insect);
void free_animal(struct animal* animal);
#endif