コード例 #1
0
ファイル: Truck.cs プロジェクト: GunioRobot/trash-2012
        /// <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);
        }
コード例 #2
0
ファイル: Tile.cs プロジェクト: GunioRobot/trash-2012
 public HouseTile(RoadType t, THouse ht, TrashType ttype, int quantity = 0) : base(t)
 {
     Garbage   = new Trash(ttype, quantity);
     HouseType = ht;
 }