using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CzokoŚmieciarka.DataModels.Exceptions; using CzokoŚmieciarka.DataModels.Interfaces.TrashCans; using CzokoŚmieciarka.DataModels.Models; namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector { public abstract class AGarbageCollector : IGarbageCollector { public AGarbageCollector(Coords startPosition, IEnumerable trashContainers, int columns, int rows) { this.columns = columns; this.rows = rows; this.Coords = startPosition; this.TrashContainers = trashContainers; } public Coords Coords { get; set; } public int columns { get; set; } public int rows { get; set; } public void MoveUp() { if(Coords.Y -1 < 0) { throw new OutOfGridException(); } Coords.Y -= 1; } public void MoveDown() { if (Coords.Y + 1 >= rows) { throw new OutOfGridException(); } Coords.Y +=1; } public void MoveLeft() { if (Coords.X - 1 < 0) { throw new OutOfGridException(); } Coords.X -= 1; } public void MoveRight() { if (Coords.X + 1 >= columns) { throw new OutOfGridException(); } Coords.X += 1; } public object Clone() { return this.MemberwiseClone(); } public IEnumerable TrashContainers { get; } } }