< Summary

Information
Class: Safarimacik.Model.Cow
Assembly: Safarimacik
File(s): /builds/szofttech-ab-2025/group-03/safarimacik/model/Herbivore.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 51
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Safarimacik.Model.Purchasable.get_Price()100%11100%
get_Nutrition()100%11100%
Mate()100%22100%
Crave()100%11100%

File(s)

/builds/szofttech-ab-2025/group-03/safarimacik/model/Herbivore.cs

#LineLine coverage
 1using Godot;
 2
 3
 4namespace Safarimacik.Model;
 5
 6
 7/// <summary>
 8/// Base class for herbivore animals.
 9/// </summary>
 10public abstract class Herbivore(Vector2 position) : Animal(position) {
 11  public abstract double Nutrition { get; }
 12}
 13
 14/// <summary>
 15/// A herbivore animal.
 16/// </summary>
 17public class Sheep(Vector2 position) : Herbivore(position), Purchasable {
 18  public const int Price = 30;
 19
 20  int Purchasable.Price => Price;
 21  public override double Nutrition => 63.5;
 22
 23  public override void Mate() {
 24    base.Mate();
 25    if (!_sex) { // is female
 26      OnOffspringSpawned(new Sheep(Position));
 27    }
 28  }
 29}
 30
 31/// <summary>
 32/// A herbivore animal.
 33/// </summary>
 134public class Cow(Vector2 position) : Herbivore(position), Purchasable {
 35  public const int Price = 33;
 36
 137  int Purchasable.Price => Price;
 138  public override double Nutrition => 73.5;
 39
 140  public override void Mate() {
 141    base.Mate();
 142    if (!_sex) { // is female
 143      OnOffspringSpawned(new Cow(Position));
 144    }
 145  }
 46
 147  public override void Crave() {
 148    _hunger -= Math.Sqrt(_age) * 0.02 + 0.01;
 149    _thirst -= Math.Sqrt(_age) * 0.01 + 0.5;
 150  }
 51}