Homework 4
In this homework you will have to write two additional @testsets 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.jlThet test/runtests.jl file can look like this:
using Test
using Ecosystem
include("sheep.jl")
include("wolf.jl")
# ...Test Sheep
Homework
Create a
Sheepwith food probabilityCreate fully grown
Grassand aWorldwith the two agents.Execute
eat!(::Animal{Sheep}, ::Plant{Grass}, ::World)@testthat the size of theGrassnow hassize == 0
Test Wolf
Homework
Create a
Wolfwith food probabilityCreate a
Sheepand aWorldwith the two agents.Execute
eat!(::Animal{Wolf}, ::Animal{Sheep}, ::World)@testthat the World only has one agent left in the agents dictionary