Homework 4
In this homework you will have to write two additional @testset
s for the Ecosystem. One testset should be contained in a file test/sheep.jl
and verify that the function eat!(::Animal{Sheep}, ::Plant{Grass}, ::World)
works correctly. Another testset should be in the file test/wolf.jl
and veryfiy that the function eat!(::Animal{Wolf}, ::Animal{Sheep}, ::World)
works correctly.
How to submit?
Zip the whole package folder Ecosystem.jl
and upload it to BRUTE. The package has to include at least the following files:
├── src
│ └── Ecosystem.jl
└── test
├── sheep.jl # contains only a single @testset
├── wolf.jl # contains only a single @testset
└── runtests.jl
Thet test/runtests.jl
file can look like this:
using Test
using Ecosystem
include("sheep.jl")
include("wolf.jl")
# ...
Test Sheep
- Create a
Sheep
with food probability $p_f=1$ - Create fully grown
Grass
and aWorld
with the two agents. - Execute
eat!(::Animal{Sheep}, ::Plant{Grass}, ::World)
@test
that the size of theGrass
now hassize == 0
Test Wolf
- Create a
Wolf
with food probability $p_f=1$ - Create a
Sheep
and aWorld
with the two agents. - Execute
eat!(::Animal{Wolf}, ::Animal{Sheep}, ::World)
@test
that the World only has one agent left in the agents dictionary