/// <summary> /// Swallow an amount of trash, /// throws an exception if the garbage type cannot be handled /// or if there is no enough place to swallow the gabage. /// </summary> /// <param name="garbage"> /// Trash to be swallowed /// </param> /// <returns>collected trash</returns> public int Swallow(Trash garbage) { if (!CanHandle(garbage.Type)) { return(0); //Unhandled garbage } var maxSwallowable = Math.Min( garbage.Amount, Capacity ); Capacity -= maxSwallowable; return(maxSwallowable); }
public HouseTile(RoadType t, THouse ht, TrashType ttype, int quantity = 0) : base(t) { Garbage = new Trash(ttype, quantity); HouseType = ht; }