This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-103-p-04-2030/HolidayTrip/Proficiencies/animals/animals.h
T
2026-02-13 16:12:39 +01:00

48 lines
911 B
C

#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