Czoko_Smieciarka/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/AGarbageCollector.cs

68 lines
1.8 KiB
C#
Raw Normal View History

2019-04-21 01:28:38 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2019-04-21 02:43:36 +02:00
using CzokoŚmieciarka.DataModels.Exceptions;
2019-04-21 01:28:38 +02:00
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
using CzokoŚmieciarka.DataModels.Models;
namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
{
2019-04-22 03:16:30 +02:00
public abstract class AGarbageCollector : IGarbageCollector, ICloneable
2019-04-21 01:28:38 +02:00
{
2019-04-21 02:43:36 +02:00
public AGarbageCollector(Coords startPosition, IEnumerable<AGarbageCollectorContainer> trashContainers, int columns, int rows)
2019-04-21 01:28:38 +02:00
{
2019-04-21 02:43:36 +02:00
this.columns = columns;
this.rows = rows;
2019-04-21 01:28:38 +02:00
this.Coords = startPosition;
this.TrashContainers = trashContainers;
}
public Coords Coords { get; set; }
2019-04-10 12:32:32 +02:00
public int columns { get; set; }
2019-04-21 02:43:36 +02:00
public int rows { get; set; }
public void MoveUp()
{
2019-04-10 12:32:32 +02:00
if(Coords.Y -1 < 0)
{
throw new OutOfGridException();
2019-04-21 02:43:36 +02:00
}
Coords.Y -= 1;
}
public void MoveDown()
{
2019-04-10 12:32:32 +02:00
if (Coords.Y + 1 >= rows)
{
throw new OutOfGridException();
2019-04-21 02:43:36 +02:00
}
Coords.Y +=1;
}
public void MoveLeft()
{
2019-04-10 12:32:32 +02:00
if (Coords.X - 1 < 0)
{
throw new OutOfGridException();
2019-04-21 02:43:36 +02:00
}
Coords.X -= 1;
}
public void MoveRight()
{
2019-04-10 12:32:32 +02:00
if (Coords.X + 1 >= columns)
{
throw new OutOfGridException();
2019-04-21 02:43:36 +02:00
}
2019-04-10 12:32:32 +02:00
Coords.X += 1;
2019-03-26 19:37:15 +01:00
}
2019-04-22 03:16:30 +02:00
public virtual object Clone()
2019-03-26 19:37:15 +01:00
{
2019-04-22 03:16:30 +02:00
throw new NotImplementedException();
2019-03-26 19:37:15 +01:00
}
2019-04-21 01:28:38 +02:00
public IEnumerable<AGarbageCollectorContainer> TrashContainers { get; }
}
}