108 lines
2.9 KiB
C#
108 lines
2.9 KiB
C#
<<<<<<< HEAD
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
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<AGarbageCollectorContainer> trashContainers)
|
||
{
|
||
this.Coords = startPosition;
|
||
this.TrashContainers = trashContainers;
|
||
}
|
||
public Coords Coords { get; set; }
|
||
|
||
public Coords MoveUp()
|
||
{
|
||
return new Coords(Coords.X,Coords.Y+1);
|
||
}
|
||
|
||
public Coords MoveDown()
|
||
{
|
||
return new Coords(Coords.X, Coords.Y - 1);
|
||
}
|
||
|
||
public Coords MoveLeft()
|
||
{
|
||
return new Coords(Coords.X-1, Coords.Y);
|
||
}
|
||
|
||
public Coords MoveRight()
|
||
{
|
||
return new Coords(Coords.X+1, Coords.Y);
|
||
=======
|
||
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<AGarbageCollectorContainer> 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;
|
||
>>>>>>> 9aaa79a5c5258bc287f1041f4b31f5a40e5cf25f
|
||
}
|
||
|
||
public object Clone()
|
||
{
|
||
return this.MemberwiseClone();
|
||
}
|
||
|
||
public IEnumerable<AGarbageCollectorContainer> TrashContainers { get; }
|
||
}
|
||
}
|