Czoko_Smieciarka/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/GarbageCollector/AGarbageCollector.cs
2019-04-21 01:30:42 +02:00

108 lines
2.9 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<<<<<<< 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; }
}
}