zmiany zabierania smieci

This commit is contained in:
Bartosz Chyzy 2019-03-13 14:51:01 +01:00
parent f12495c1b4
commit e89d892f79
5 changed files with 18 additions and 11 deletions

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace CzokoŚmieciarka.DataModels.Interfaces namespace CzokoŚmieciarka.DataModels.Interfaces
{ {
public abstract class AGarbage : IGarbage public abstract class AGarbage : IGarbage, ICloneable
{ {
protected AGarbage(ITypeOfGarbage typeOfGarbage, int weight) protected AGarbage(ITypeOfGarbage typeOfGarbage, int weight)
{ {
@ -15,7 +15,7 @@ namespace CzokoŚmieciarka.DataModels.Interfaces
} }
public ITypeOfGarbage TypeOfGarbage { get; } public ITypeOfGarbage TypeOfGarbage { get; }
public virtual int Weight { get; } public virtual int Weight { get; set; }
public virtual int Volume public virtual int Volume
{ {
@ -37,5 +37,10 @@ namespace CzokoŚmieciarka.DataModels.Interfaces
return a.Subtract(b); return a.Subtract(b);
} }
#endregion #endregion
public object Clone()
{
return this.MemberwiseClone();
}
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
using CzokoŚmieciarka.DataModels.Models; using CzokoŚmieciarka.DataModels.Models;
namespace CzokoŚmieciarka.DataModels.Interfaces namespace CzokoŚmieciarka.DataModels.Interfaces

View File

@ -8,6 +8,10 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.RoutePlanningEngine
{ {
public abstract class ARoutePlanningEngine public abstract class ARoutePlanningEngine
{ {
protected IGarbageCollector garbageCollector;
protected IEnumerable<IGarbageLocalization> garbageLocalizations;
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
namespace CzokoŚmieciarka.DataModels.Interfaces namespace CzokoŚmieciarka.DataModels.Interfaces
{ {

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CzokoŚmieciarka.DataModels.Interfaces namespace CzokoŚmieciarka.DataModels.Interfaces.TrashCans
{ {
public abstract class ATrashCan public abstract class ATrashCan
{ {
@ -28,7 +24,7 @@ namespace CzokoŚmieciarka.DataModels.Interfaces
public virtual bool AddGarbage(AGarbage garbage) public virtual bool AddGarbage(AGarbage garbage)
{ {
if (this._typeOfGarbage != garbage.TypeOfGarbage) if (this._typeOfGarbage != garbage.TypeOfGarbage)
return false; throw new Exception("You cannot add up different type garbage!");
var newGarbage = this.Garbage + Garbage; var newGarbage = this.Garbage + Garbage;
if (newGarbage.Volume > this.MaxVolume) if (newGarbage.Volume > this.MaxVolume)
@ -40,8 +36,8 @@ namespace CzokoŚmieciarka.DataModels.Interfaces
public virtual AGarbage TakeGarbage() public virtual AGarbage TakeGarbage()
{ {
var result = this.Garbage; var result = (AGarbage)this.Garbage.Clone();
this.Garbage = null; this.Garbage.Weight = 0;
return result; return result;
} }
} }