< Summary

Information
Class: Safarimacik.Model.Predator
Assembly: Safarimacik
File(s): /builds/szofttech-ab-2025/group-03/safarimacik/model/Predator.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 52
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)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>
 110public 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>
 36public class Fox(Vector2 position) : Predator(position), Purchasable {
 37  public const int Price = 20;
 38
 39  int Purchasable.Price => Price;
 40
 41  public override void Mate() {
 42    base.Mate();
 43    if (!_sex) { // is female
 44      OnOffspringSpawned(new Fox(Position));
 45    }
 46  }
 47
 48  public override void Crave() {
 49    _hunger -= Math.Sqrt(_age) * 0.02 + 0.1;
 50    _thirst -= Math.Sqrt(_age) * 0.005;
 51  }
 52}

Methods/Properties

.ctor(Godot.Vector2)