Czoko_Smieciarka/Trunk/Components/CzokoŚmieciarka.DataModels/Interfaces/TrashCans/ATrashCan.cs
2019-03-13 14:31:11 +01:00

49 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CzokoŚmieciarka.DataModels.Interfaces
{
public abstract class ATrashCan
{
protected ATrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume)
{
this.MaxVolume = maxVolume;
this._typeOfGarbage = typeOfGarbage;
}
protected ITypeOfGarbage _typeOfGarbage;
public int MaxVolume { get;}
public AGarbage Garbage { get; private set; }
public int FillPercent
{
get { return Garbage.Volume / this.MaxVolume; }
}
public virtual bool AddGarbage(AGarbage garbage)
{
if (this._typeOfGarbage != garbage.TypeOfGarbage)
return false;
var newGarbage = this.Garbage + Garbage;
if (newGarbage.Volume > this.MaxVolume)
return false;
this.Garbage = newGarbage;
return true;
}
public virtual AGarbage TakeGarbage()
{
var result = this.Garbage;
this.Garbage = null;
return result;
}
}
}