Esempio n. 1
0
 public bool Transfer(Bucket source, Bucket target)
 {
     if (target.Add(source.Volume))
     {
         return(source.EmptyBucket());
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        public bool Transfer(Bucket source, Bucket target, int volume)
        {
            // constraint Transfer should only go through if a bucket is filled or a bucket is emptied
            int sourceVolume = source.Volume;
            int targetVolume = target.Volume;

            if (sourceVolume - volume == 0 || targetVolume + volume == target.BucketSize)
            {
                if (target.Add(volume))
                {
                    return(source.Subtract(volume));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }