コード例 #1
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            Dye dye = new Dye(power);

            if (bunnies.FindByName(bunnyName) == null)
            {
                throw new InvalidOperationException("The bunny you want to add a dye to doesn't exist!");
            }

            bunnies.FindByName(bunnyName).AddDye(dye);

            return($"Successfully added dye with power {dye.Power} to bunny {bunnyName}!");
        }
コード例 #2
0
        public string AddDyeToBunny(string bunnyName, int power) //ok?
        {
            IBunny bunny = bunnies.FindByName(bunnyName);

            if (bunny == null)
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentBunny));
            }
            Dye dye = new Dye(power);

            bunny.AddDye(dye);
            return($"Successfully added dye with power {power} to bunny {bunnyName}!");
        }
コード例 #3
0
ファイル: Controller.cs プロジェクト: Zgencheva/C--OOP
        public string AddDyeToBunny(string bunnyName, int power)
        {
            IBunny currentBunny = bunnies.FindByName(bunnyName);

            if (currentBunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }
            IDye currentDye = new Dye(power);

            currentBunny.AddDye(currentDye);
            return($"{String.Format(OutputMessages.DyeAdded, power, bunnyName)}");
        }
コード例 #4
0
        public string AddDyeToBunny(string bunnyName, int power)
        {
            Dye    dye   = new Dye(power);
            IBunny bunny = bunnies.FindByName(bunnyName);

            if (bunny == null)
            {
                throw new InvalidOperationException(ExceptionMessages.InexistentBunny);
            }

            bunny.AddDye(dye);
            return(string.Format(OutputMessages.DyeAdded, power, bunnyName));
        }