< Summary

Information
Class: Safarimacik.Model.Fox
Assembly: Safarimacik
File(s): /builds/szofttech-ab-2025/group-03/safarimacik/model/Predator.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 52
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%
Mate()100%22100%
Crave()100%11100%

File(s)

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

#LineLine coverage
 1using Godot;
 2
 3
 4namespace Safarimacik.Model;
 5
 6
 7/// <summary>
 8/// Base class for predator animals.
 9/// </summary>
 10public abstract class Predator(Vector2 position) : Animal(position) { }
 11
 12/// <summary>
 13/// A predator animal.
 14/// </summary>
 15public class Wolf(Vector2 position) : Predator(position), Purchasable {
 16  public const int Price = 14;
 17
 18  int Purchasable.Price => Price;
 19
 20  public override void Mate() {
 21    base.Mate();
 22    if (!_sex) { // is female
 23      OnOffspringSpawned(new Wolf(Position));
 24    }
 25  }
 26
 27  public override void Crave() {
 28    _hunger -= Math.Sqrt(_age) * 0.02 + 0.05;
 29    _thirst -= Math.Sqrt(_age) * 0.005 + 0.05;
 30  }
 31}
 32
 33/// <summary>
 34/// A predator animal.
 35/// </summary>
 136public class Fox(Vector2 position) : Predator(position), Purchasable {
 37  public const int Price = 20;
 38
 139  int Purchasable.Price => Price;
 40
 141  public override void Mate() {
 142    base.Mate();
 143    if (!_sex) { // is female
 144      OnOffspringSpawned(new Fox(Position));
 145    }
 146  }
 47
 148  public override void Crave() {
 149    _hunger -= Math.Sqrt(_age) * 0.02 + 0.1;
 150    _thirst -= Math.Sqrt(_age) * 0.005;
 151  }
 52}