< Summary

Information
Class: Safarimacik.Model.Sheep
Assembly: Safarimacik
File(s): /builds/szofttech-ab-2025/group-03/safarimacik/model/Herbivore.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
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%

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>
 117public class Sheep(Vector2 position) : Herbivore(position), Purchasable {
 18  public const int Price = 30;
 19
 120  int Purchasable.Price => Price;
 121  public override double Nutrition => 63.5;
 22
 123  public override void Mate() {
 124    base.Mate();
 125    if (!_sex) { // is female
 126      OnOffspringSpawned(new Sheep(Position));
 127    }
 128  }
 29}
 30
 31/// <summary>
 32/// A herbivore animal.
 33/// </summary>
 34public class Cow(Vector2 position) : Herbivore(position), Purchasable {
 35  public const int Price = 33;
 36
 37  int Purchasable.Price => Price;
 38  public override double Nutrition => 73.5;
 39
 40  public override void Mate() {
 41    base.Mate();
 42    if (!_sex) { // is female
 43      OnOffspringSpawned(new Cow(Position));
 44    }
 45  }
 46
 47  public override void Crave() {
 48    _hunger -= Math.Sqrt(_age) * 0.02 + 0.01;
 49    _thirst -= Math.Sqrt(_age) * 0.01 + 0.5;
 50  }
 51}