< Summary

Information
Class: Safarimacik.Model.RegeneratingPlant
Assembly: Safarimacik
File(s): /builds/szofttech-ab-2025/group-03/safarimacik/model/RegeneratingPlant.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 54
Line coverage: 100%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_IsRipe()100%11100%
Consume()50%22100%
DecreaseCurrentCooldown()75%44100%

File(s)

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

#LineLine coverage
 1namespace Safarimacik.Model;
 2
 3
 4/// <summary>
 5/// Base class for regenerating plants.
 6/// </summary>
 17public abstract class RegeneratingPlant(double nutrition, int cooldown, bool isRipe) : Plant(nutrition) {
 18  public readonly int Cooldown = cooldown;
 9
 10  protected int _currentCooldown;
 111  protected bool _isRipe = isRipe;
 12
 13  public event Action? StateChanged;
 14
 115  public bool IsRipe => _isRipe;
 16
 117  public void Consume() {
 118    _isRipe = false;
 119    _currentCooldown = Cooldown;
 120    StateChanged?.Invoke();
 121  }
 22
 123  public void DecreaseCurrentCooldown() {
 124    --_currentCooldown;
 125    if (_currentCooldown == 0) {
 126      _isRipe = true;
 127      StateChanged?.Invoke();
 128    }
 129  }
 30}
 31
 32/// <summary>
 33/// Represents a regenerating, placeable
 34/// </summary>
 35public class Tree : RegeneratingPlant, Purchasable {
 36  public const int Price = 80;
 37  public new const int Cooldown = 120;
 38
 39  int Purchasable.Price => Price;
 40
 41  public Tree() : base(50, Cooldown, true) { }
 42}
 43
 44/// <summary>
 45/// Represents a regenerating, placeable
 46/// </summary>
 47public class Bush : RegeneratingPlant, Purchasable {
 48  public const int Price = 115;
 49  public new const int Cooldown = 60;
 50
 51  int Purchasable.Price => Price;
 52
 53  public Bush() : base(60, Cooldown, true) { }
 54}