2019-04-21 01:30:42 +02:00
|
|
|
|
<<<<<<< HEAD
|
2019-04-21 01:28:38 +02:00
|
|
|
|
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);
|
2019-04-21 01:30:42 +02:00
|
|
|
|
=======
|
2019-03-13 14:19:38 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-04-10 12:32:32 +02:00
|
|
|
|
using CzokoŚmieciarka.DataModels.Exceptions;
|
2019-03-13 17:23:52 +01:00
|
|
|
|
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
|
2019-03-13 14:19:38 +01:00
|
|
|
|
using CzokoŚmieciarka.DataModels.Models;
|
|
|
|
|
|
|
|
|
|
namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
|
|
|
|
|
{
|
|
|
|
|
public abstract class AGarbageCollector : IGarbageCollector
|
|
|
|
|
{
|
2019-04-10 12:32:32 +02:00
|
|
|
|
public AGarbageCollector(Coords startPosition, IEnumerable<AGarbageCollectorContainer> trashContainers, int columns, int rows)
|
|
|
|
|
{
|
|
|
|
|
this.columns = columns;
|
|
|
|
|
this.rows = rows;
|
2019-04-08 17:07:08 +02:00
|
|
|
|
this.Coords = startPosition;
|
2019-03-13 14:19:38 +01:00
|
|
|
|
this.TrashContainers = trashContainers;
|
|
|
|
|
}
|
2019-04-10 12:32:32 +02:00
|
|
|
|
public Coords Coords { get; set; }
|
|
|
|
|
public int columns { get; set; }
|
|
|
|
|
public int rows { get; set; }
|
|
|
|
|
public void MoveUp()
|
2019-03-13 14:19:38 +01:00
|
|
|
|
{
|
2019-04-10 12:32:32 +02:00
|
|
|
|
if(Coords.Y -1 < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new OutOfGridException();
|
|
|
|
|
}
|
|
|
|
|
Coords.Y -= 1;
|
2019-03-13 14:19:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 12:32:32 +02:00
|
|
|
|
public void MoveDown()
|
2019-03-13 14:19:38 +01:00
|
|
|
|
{
|
2019-04-10 12:32:32 +02:00
|
|
|
|
if (Coords.Y + 1 >= rows)
|
|
|
|
|
{
|
|
|
|
|
throw new OutOfGridException();
|
|
|
|
|
}
|
|
|
|
|
Coords.Y +=1;
|
2019-03-13 14:19:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 12:32:32 +02:00
|
|
|
|
public void MoveLeft()
|
2019-03-13 14:19:38 +01:00
|
|
|
|
{
|
2019-04-10 12:32:32 +02:00
|
|
|
|
if (Coords.X - 1 < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new OutOfGridException();
|
|
|
|
|
}
|
|
|
|
|
Coords.X -= 1;
|
2019-03-13 14:19:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 12:32:32 +02:00
|
|
|
|
public void MoveRight()
|
2019-03-13 14:19:38 +01:00
|
|
|
|
{
|
2019-04-10 12:32:32 +02:00
|
|
|
|
if (Coords.X + 1 >= columns)
|
|
|
|
|
{
|
|
|
|
|
throw new OutOfGridException();
|
|
|
|
|
}
|
|
|
|
|
Coords.X += 1;
|
2019-04-21 01:30:42 +02:00
|
|
|
|
>>>>>>> 9aaa79a5c5258bc287f1041f4b31f5a40e5cf25f
|
2019-03-26 19:37:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Clone()
|
|
|
|
|
{
|
|
|
|
|
return this.MemberwiseClone();
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-21 01:28:38 +02:00
|
|
|
|
public IEnumerable<AGarbageCollectorContainer> TrashContainers { get; }
|
|
|
|
|
}
|
|
|
|
|
}
|