Imagine you are designing a new video game and you have to create food that the players can eat to gain strength.
Imagine you are designing a new video game, and your next feature is to create food that the players can eat to gain strength.
There are two types of food for now:
- Fruit: increase the strength by 4 units per each kilogram of fruit consumed.
- Meat: has the weight in kilograms `weight_in_kg` (which is the weight of the whole piece) and the `fat_content` which corresponds to the percentage of the weight which is pure fat (the rest is considered protein) each kilogram of protein gives 4 units of `strength` and each kilogram of fat gives 9 units of `strength`.
- `Fruit`: increases the strength by 4 units for each kilogram of fruit consumed.
- `Meat`: has a weight in kilograms, and it's pure fat content as a percentage. The remaining weight of meat which is not pure fat is considered to be protein. Each kilogram of protein increases the strength by 4 units. Each kilogram of fat increases the strength by 9 units.
Define the `Food` trait for `Fruit` and `Meat`. The required method `gives()` represents the energy that the food provides.
Implement the `std::fmt::Display` trait for `Player` structure in a way that when using the template `{}` inside a println! macro it will print:
- In the first line, the name of the player
- In the second line the strength, score and the money
Define the `Food` trait for `Fruit` and `Meat`. The required method `gives` returns the amount of strength that the food provides.
Implement the `std::fmt::Display` trait for the `Player` structure, so that when `{}` corresponds to a `Player` insider a `println!` macro, it will print 3 lines: