diff options
| author | Fuwn <[email protected]> | 2025-10-30 17:01:14 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-10-30 17:01:14 -0700 |
| commit | 5cdde428a7f966f17f0a94eca7b94fbf1e499838 (patch) | |
| tree | 5f94122032752e2561009ef1c5e5b6641c5fb73c /MorgSimulator/Morg.cs | |
| parent | refactor(diagrams): Move present diagrams to assignment folder (diff) | |
| download | cst276-5cdde428a7f966f17f0a94eca7b94fbf1e499838.tar.xz cst276-5cdde428a7f966f17f0a94eca7b94fbf1e499838.zip | |
feat: Implement Assignment 2 functionality
Diffstat (limited to 'MorgSimulator/Morg.cs')
| -rw-r--r-- | MorgSimulator/Morg.cs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/MorgSimulator/Morg.cs b/MorgSimulator/Morg.cs index 62048bf..cfac9dd 100644 --- a/MorgSimulator/Morg.cs +++ b/MorgSimulator/Morg.cs @@ -3,16 +3,16 @@ using System.Linq; namespace MorgSimulator { - public abstract class Morg(int id, (int x, int y) location, (int x, int y) direction) + public class Morg(int id, (int x, int y) location, (int x, int y) direction) { public int Id { get; set; } = id; - public string Type { get; protected set; } = string.Empty; + public string Type { get; set; } = string.Empty; public (int x, int y) Location { get; set; } = location; public (int x, int y) Direction { get; set; } = direction; public bool IsAlive { get; set; } = true; - public IMovementStrategy MovementStrategy { get; protected set; } = null!; - public IFeedingStrategy FeedingStrategy { get; protected set; } = null!; - public List<string> PreyTypes { get; protected set; } = new List<string>(); + public IMovementStrategy MovementStrategy { get; set; } = null!; + public IFeedingStrategy FeedingStrategy { get; set; } = null!; + public List<string> PreyTypes { get; set; } = []; #nullable enable public Morg? Prey { get; set; } #nullable disable @@ -32,16 +32,16 @@ namespace MorgSimulator public void Notify() { - foreach (var observer in _observers.ToList()) + foreach (var observer in _observers) observer.Update(this); } - public virtual void Update(Morg subject) + public void Update(Morg subject) { Direction = CalculateDirectionToTarget(subject.Location); } - public virtual void Move() + public void Move() { if (!IsAlive) return; @@ -51,7 +51,7 @@ namespace MorgSimulator Notify(); } - public virtual void Feed() + public void Feed() { if (!IsAlive || Prey == null || !Prey.IsAlive) return; |