Ejemplo n.º 1
0
        public ICoin GetCoin(int coinTypeId)
        {
            ICoin coin;

            switch (coinTypeId)
            {
            case 1:
                coin = new Nickle();
                break;

            case 5:
                coin = new Penny();
                break;

            case 10:
                coin = new Qaurter();
                break;

            case 25:
                coin = new Dime();
                break;

            default:
                coin = new NoCoin();
                break;
            }
            return(coin);
        }
Ejemplo n.º 2
0
        public void WhenAddCoin_CoinShouldBeAdded()
        {
            ICoinCollection coinCollection = Mocker.CreateInstance <CoinCollection>();
            ICoin           coin           = new Nickle();

            coinCollection.AddCoin(coin);

            coinCollection.Should().BeEquivalentTo(new [] { coin });
        }
Ejemplo n.º 3
0
        //Properties



        //Contructors initialize values upon instantiation.


        //Methods do something.
        public void DispenseCoins()
        {
            //Will these objects retain their data even though they're instantiated in a method and as member variables?
            Dime    Dimes    = new Dime();
            Nickle  Nickles  = new Nickle();
            Penny   Pennies  = new Penny();
            Quarter Quarters = new Quarter();

            for (int index = 0; index < 20; index++)
            {
                List <Coin> Coin = new List <Coin>();
                register.Add("Quarters");//This error under Add occurred when I instantiated the lists.
                Console.WriteLine(index);
                balanceOfQuarters = index;
            }

            for (int index = 0; index < 10; index++)
            {
                List <Coin> Coin = new List <Coin>();
                register.Add("Dimes");
                Console.WriteLine(index);
                balanceOfDimes = index;
            }

            for (int index = 0; index < 20; index++)
            {
                List <Coin> Coin = new List <Coin>();
                register.Add("Nickles");
                Console.WriteLine(index);
                balanceOfNickels = index;
            }

            for (int index = 0; index < 50; index++)
            {
                List <Coin> register = new List <Coin>();
                register.Add("Pennies");
                Console.WriteLine(index);
                balanceOfPennies = index;
            }
            Console.WriteLine();
        }
Ejemplo n.º 4
0
        //Methods do something.
        public void KeepTrackOfCoins()
        {
            Quarter Quarters = new Quarter();
            Dime    Dimes    = new Dime();
            Nickle  Nickles  = new Nickle();
            Penny   Pennies  = new Penny();

            for (int index = 0; index < 12; index++)
            {
                List <Coin> Coin = new List <Coin>();
                Coin.Add("Quarters");//This error under Add occurred when I instantiated the lists.
                Console.WriteLine(index);
                walletBalanceOfQuarters = index;
            }

            for (int index = 0; index < 10; index++)
            {
                List <Coin> Coin = new List <Coin>();
                Coin.Add("Dimes");
                Console.WriteLine(index);
                walletBalanceOfDimes = index;
            }

            for (int index = 0; index < 15; index++)
            {
                List <Coin> Coin = new List <Coin>();
                Coin.Add("Nickles");
                Console.WriteLine(index);
                walletBalanceOfNickels = index;
            }

            for (int index = 0; index < 25; index++)
            {
                List <Coin> register = new List <Coin>();
                Coin.Add("Pennies");
                Console.WriteLine(index);
                walletBalanceOfPennies = index;
            }
            Console.WriteLine();
        }