Ejemplo n.º 1
0
        //Member Methods (Can Do)
        //Fills wallet with starting money
        private void FillRegister()
        {
            for (int i = 0; i < 20; i++)
            {
                Coin myCoin = new Quarter();
                Coins.Add(myCoin);
            }
            for (int i = 0; i < 10; i++)
            {
                Coin myCoin = new Dime();
                Coins.Add(myCoin);
            }
            for (int i = 0; i < 20; i++)
            {
                Coin myCoin = new Nickel();
                Coins.Add(myCoin);
            }
            for (int i = 0; i < 50; i++)
            {
                Coin myCoin = new Penny();
                Coins.Add(myCoin);
            }

            Card myCard = new Card();

            myCard.availableFunds.Equals(100);
        }
Ejemplo n.º 2
0
        //Member Methods (Can Do)

        //A method to fill the sodamachines register with coin objects.
        public void FillRegister()
        {
            // I want to add coin objects to my register
            // 20 quarters, 10 dimes, 20 nickels, 50 pennies
            // Create coin objects
            // Then add them to the register
            // A for loop would allow us to do the "create coin, then add" operation
            // multiple times and stop at a certain number

            for (int i = 0; i <= 20; i++)
            {
                Quarter quarter = new Quarter();
                _register.Add(quarter);
            }
            for (int i = 0; i < 10; i++)
            {
                Dime dime = new Dime();
                _register.Add(dime);
            }
            for (int i = 0; i < 20; i++)
            {
                Nickel nickel = new Nickel();
                _register.Add(nickel);
            }
            for (int i = 0; i < 50; i++)
            {
                Penny penny = new Penny();
                _register.Add(penny);
            }
        }
Ejemplo n.º 3
0
        //Member Methods (Can Do)
        //Fills wallet with starting money
        private void FillRegister()
        {
            for (int i = 0; i <= 8; i++)
            {
                Quarter quarter = new Quarter();
                Coins.Add(quarter);
            }

            for (int i = 0; i <= 15; i++)
            {
                Dime dime = new Dime();
                Coins.Add(dime);
            }

            for (int i = 0; i <= 20; i++)
            {
                Nickel nickel = new Nickel();
                Coins.Add(nickel);
            }

            for (int i = 0; i <= 50; i++)
            {
                Penny penny = new Penny();
                Coins.Add(penny);
            }
        }
Ejemplo n.º 4
0
        public SodaMachineA()
        {
            register = new List <Coin>();
            cans     = new List <Can>();

            Quarter quarter = new Quarter();

            SetStartingMoney(20, quarter);

            Nickel nickel = new Nickel();

            SetStartingMoney(20, nickel);

            Penny penny = new Penny();

            SetStartingMoney(50, penny);

            Dime dime = new Dime();

            SetStartingMoney(10, dime);

            Cola cola = new Cola();

            SetStartingCans(10, cola);

            OrangeSoda orange = new OrangeSoda();

            SetStartingCans(10, orange);

            RootBeer rootbeer = new RootBeer();

            SetStartingCans(10, rootbeer);
        }
Ejemplo n.º 5
0
        //Member Methods (Can Do)
        //Fills wallet with starting money
        private void FillRegister()
        {
            Coins = new List <Coin>();
            Coin quarter = new Quarter();
            Coin dime    = new Dime();
            Coin nickel  = new Nickel();
            Coin penny   = new Penny();

            Coins.Add(quarter);
            Coins.Add(dime);
            Coins.Add(nickel);
            Coins.Add(penny);

            for (int i = 0; i < 12; i++)
            {
                Coins.Add(quarter);
            }
            for (int i = 0; i < 16; i++)
            {
                Coins.Add(dime);
            }
            for (int i = 0; i < 6; i++)
            {
                Coins.Add(nickel);
            }
            for (int i = 0; i < 10; i++)
            {
                Coins.Add(penny);
            }
        }
Ejemplo n.º 6
0
        public List <Coin> GetCoinsList(int[] coinSelection)
        {
            List <Coin> output = new List <Coin>();

            for (int i = 0; i < coinSelection.Length; i++)
            {
                for (int j = 0; j < coinSelection[i]; j++)
                {
                    Coin coin;
                    switch (i)
                    {
                    case 0:
                        coin = new Quarter();
                        output.Add(coin);
                        break;

                    case 1:
                        coin = new Dime();
                        output.Add(coin);
                        break;

                    case 2:
                        coin = new Nickel();
                        output.Add(coin);
                        break;

                    case 3:
                        coin = new Penny();
                        output.Add(coin);
                        break;
                    }
                }
            }
            return(output);
        }
Ejemplo n.º 7
0
        //Member Methods (Can Do)

        //A method to fill the sodamachines register with coin objects.
        public void FillRegister()
        {
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            for (int i = 0; i < 20; i++)
            {
                _register.Add(quarter);
            }

            for (int i = 0; i < 10; i++)
            {
                _register.Add(dime);
            }

            for (int i = 0; i < 20; i++)
            {
                _register.Add(nickel);
            }

            for (int i = 0; i < 50; i++)
            {
                _register.Add(penny);
            }
        }
Ejemplo n.º 8
0
 public void InitializeRegister()
 {
     for (int i = 0; i < 20; i++)
     {
         quarter = new Quarter();
         register.Add(quarter);
     }
     //20 quarters
     for (int i = 0; i < 10; i++)
     {
         dime = new Dime();
         register.Add(dime);
     }
     //10 dimes
     for (int i = 0; i < 20; i++)
     {
         nickel = new Nickel();
         register.Add(nickel);
     }
     for (int i = 0; i < 50; i++)
     {
         penny = new Penny();
         register.Add(penny);
     }
 }
Ejemplo n.º 9
0
        //Member Methods (Can Do)

        //A method to fill the sodamachines register with coin objects.
        public void FillRegister()
        {
            for (int i = 0; i <= 20; i++)
            {
                Quarter quarter = new Quarter(); // self note: here we are INSTANTIATING a NEW coin(QUARTER) each time !!!
                _register.Add(quarter);
            }

            for (int i = 0; i <= 10; i++)
            {
                Dime dime = new Dime();
                _register.Add(dime);
            }

            for (int i = 0; i <= 20; i++)
            {
                Nickel nickel = new Nickel();
                _register.Add(nickel);
            }

            for (int i = 0; i <= 50; i++)
            {
                Penny penny = new Penny();
                _register.Add(penny);
            }
        }
Ejemplo n.º 10
0
        //Member Methods (Can Do)

        //A method to fill the sodamachines register with coin objects.
        public void FillRegister()
        {
            _register = new List <Coin>();
            Coin quarter = new Quarter();
            Coin dime    = new Dime();
            Coin nickel  = new Nickel();
            Coin penny   = new Penny();

            _register.Add(quarter);
            _register.Add(dime);
            _register.Add(nickel);
            _register.Add(penny);

            for (int i = 0; i < 20; i++)
            {
                _register.Add(quarter);
            }
            for (int i = 0; i < 10; i++)
            {
                _register.Add(dime);
            }
            for (int i = 0; i < 20; i++)
            {
                _register.Add(nickel);
            }
            for (int i = 0; i < 50; i++)
            {
                _register.Add(penny);
            }
        }
Ejemplo n.º 11
0
 private void AddNickelsToWallet(int startingNickels)
 {
     for (int i = 0; i < startingNickels; i++)
     {
         Nickel nickel = new Nickel();
         Coins.Add(nickel);
     }
 }
Ejemplo n.º 12
0
 private void AddNickels(int count)
 {
     for (int i = 0; i < count; i++)
     {
         Coin coin = new Nickel();
         coins.Add(coin);
     }
 }
Ejemplo n.º 13
0
 public void AddNickelToCashBox(int numberOfNickels)
 {
     for (int i = 0; i < numberOfNickels; i++)
     {
         Nickel nickel = new Nickel();
         nickels.Add(nickel);
     }
 }
Ejemplo n.º 14
0
 private void StockNickels()
 {
     for (int i = 0; i < 20; i++)
     {
         Nickel nickel = new Nickel();
         register.Add(nickel);
     }
 }
Ejemplo n.º 15
0
 public void AddNickels()
 {
     for (int i = 0; i < 20; i++)
     {
         Nickel addNickels = new Nickel();
         NickelHolder.Add(addNickels);
     }
 }
Ejemplo n.º 16
0
 private void AddNickelsToRegister(int startingNickels)
 {
     for (int i = 0; i < startingNickels; i++)
     {
         Nickel nickel = new Nickel();
         _register.Add(nickel);
     }
 }
Ejemplo n.º 17
0
 public void AddNickelsToWallet()
 {
     for (int i = 0; i < 16; i++)
     {
         Nickel nickel = new Nickel();
         coins.Add(nickel);
     }
 }
 public void AddNickels()
 {
     Nickels = new List <Nickel>();
     for (int i = 0; i < 20; i++)
     {
         Nickel nickel = new Nickel();
         Nickels.Add(nickel);
     }
 }
Ejemplo n.º 19
0
        public void PayingInNickels()
        {
            Console.WriteLine("How many nickels are you putting in?");
            usersNickel = int.Parse(Console.ReadLine());

            for (int i = 0; i < usersNickel; i++)
            {
                Nickel n = new Nickel();
                userCoinPurse.Add(n);
            }
        }
Ejemplo n.º 20
0
        private int[] MakeChange(double change)
        {
            bool    success = true;
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickle  = new Nickel();
            Penny   penny   = new Penny();

            int[] changeReturned = new int[4] {
                0, 0, 0, 0
            };
            do
            {
                if (change > quarter.Value && RegisterContainsCoin(quarter.name))
                {
                    success = RemoveCoinFromRegister(quarter.name);
                    change -= quarter.Value;
                    changeReturned[0]++;
                }
                else if (change > dime.Value && RegisterContainsCoin(dime.name))
                {
                    success = RemoveCoinFromRegister(dime.name);
                    change -= dime.Value;
                    changeReturned[1]++;
                }
                else if (change > nickle.Value && RegisterContainsCoin(nickle.name))
                {
                    success = RemoveCoinFromRegister(nickle.name);
                    change -= nickle.Value;
                    changeReturned[2]++;
                }
                else if (change > penny.Value && RegisterContainsCoin(penny.name))
                {
                    //else if (change>penny.Value && RegisterContainsCoin(penny.name))
                    //why are we always using doubles for money? Decimals are for money.
                    success = RemoveCoinFromRegister(penny.name);
                    change -= penny.Value;
                    changeReturned[3]++;
                }
                else
                {
                    success = false;
                }
            } while (change >= 1 && success == true);
            if (success)
            {
                return(changeReturned);
            }
            else
            {
                AddToRegister(changeReturned[0], changeReturned[1], changeReturned[2], changeReturned[3]);
                return(null);
            }
        }
Ejemplo n.º 21
0
        //Member Methods (Can Do)

        //A method to fill the sodamachines register with coin objects.
        public void FillRegister()
        {
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            AdministratorDepositCoinsIntoRegister(quarter, 20);
            AdministratorDepositCoinsIntoRegister(dime, 10);
            AdministratorDepositCoinsIntoRegister(nickel, 20);
            AdministratorDepositCoinsIntoRegister(penny, 50);
        }
Ejemplo n.º 22
0
        //Member Methods (Can Do)
        //Fills wallet with starting money
        private void FillRegister()
        {
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            InitialDepositOfCoinsIntoWallet(quarter, 14);
            InitialDepositOfCoinsIntoWallet(dime, 11);
            InitialDepositOfCoinsIntoWallet(nickel, 6);
            InitialDepositOfCoinsIntoWallet(penny, 10);
        }
Ejemplo n.º 23
0
 void FillWallet()
 {
     quarter = new Quarter();
     dime    = new Dime();
     nickel  = new Nickel();
     penny   = new Penny();
     Functions.CreateCoins(quarter, 9, coin);
     Functions.CreateCoins(dime, 17, coin);
     Functions.CreateCoins(nickel, 8, coin);
     Functions.CreateCoins(penny, 83, coin);
     card.AvailableFunds = 1.32;
 }
Ejemplo n.º 24
0
        //Constructor (Spawner)
        public Wallet()
        {
            Coins = new List <Coin>();

            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            FillRegister(1, quarter);
            FillRegister(5, dime);
            FillRegister(12, nickel);
            FillRegister(15, penny);
        }
Ejemplo n.º 25
0
        private double CountChange(int quarters, int dimes, int nickels, int pennies)
        {
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickle  = new Nickel();
            Penny   penny   = new Penny();
            double  value   = 0;

            value += quarter.Value * quarters;
            value += dime.Value * dimes;
            value += nickle.Value * nickels;
            value += penny.Value * pennies;

            return(value);
        }
Ejemplo n.º 26
0
        //Takes in the value of the amount of change needed.
        //Attempts to gather all the required coins from the sodamachine's register to make change.
        //Returns the list of coins as change to despense.
        //If the change cannot be made, return null.
        private List <Coin> GatherChange(double changeValue)
        {
            List <Coin> coins   = new List <Coin>();
            Quarter     quarter = new Quarter();
            Dime        dime    = new Dime();
            Nickel      nickel  = new Nickel();
            Penny       penny   = new Penny();


            while (changeValue >= 0.25)
            {
                if (RegisterHasCoin("Quarter"))
                {
                    _register.Remove(quarter);
                    coins.Add(quarter);
                    changeValue = changeValue - quarter.Value;
                }
            }
            while (changeValue >= 0.10)
            {
                if (RegisterHasCoin("Dime"))
                {
                    _register.Remove(dime);
                    coins.Add(dime);
                    changeValue = changeValue - dime.Value;
                }
            }
            while (changeValue >= 0.05)
            {
                if (RegisterHasCoin("Nickel"))
                {
                    _register.Remove(nickel);
                    coins.Add(nickel);
                    changeValue = changeValue - nickel.Value;
                }
            }
            while (changeValue >= 0.01)
            {
                if (RegisterHasCoin("Penny"))
                {
                    _register.Remove(penny);
                    coins.Add(penny);
                    changeValue = changeValue - penny.Value;
                }
            }
            return(coins);
            //return list of coins coins
        }
Ejemplo n.º 27
0
        //Constructor (Spawner)
        public Wallet()
        {
            Coins = new List <Coin>();

            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickle  = new Nickel();
            Penny   penny   = new Penny();

            FillRegister(quarter, 12);
            FillRegister(dime, 10);
            FillRegister(nickle, 20);
            FillRegister(penny, 25);

            // FillRegister();
        }
Ejemplo n.º 28
0
        //member methods
        private void fillSodaMachine()
        {
            quarter    = new Quarter();
            dime       = new Dime();
            nickel     = new Nickel();
            penny      = new Penny();
            orangeSoda = new OrangeSoda();
            rootBeer   = new RootBeer();
            cola       = new Cola();
            Functions.CreateCans(cola, 5, inventory);
            Functions.CreateCans(orangeSoda, 9, inventory);
            Functions.CreateCans(rootBeer, 1, inventory);

            Functions.CreateCoins(quarter, 20, register); //20
            Functions.CreateCoins(dime, 10, register);    //10
            Functions.CreateCoins(nickel, 20, register);  //20
            Functions.CreateCoins(penny, 50, register);   //50
        }
Ejemplo n.º 29
0
        public static double WhatsInMyWallet(Wallet wallet)
        {
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            int    quarters = 0;
            int    dimes    = 0;
            int    nickels  = 0;
            int    pennies  = 0;
            double value    = 0;

            foreach (Coin coin in wallet.coins)
            {
                if (coin.name == quarter.name)
                {
                    quarters -= -1;
                }
                else if (coin.name == dime.name)
                {
                    dimes -= -1;
                }
                else if (coin.name == nickel.name)
                {
                    nickels -= -1;
                }
                else if (coin.name == penny.name)
                {
                    pennies -= -1;
                }
                else
                {
                    Console.WriteLine("something went wrong counting coins. Contact the developer of this application. : WhatsInMyWallet()");
                }

                value += coin.Value;
            }
            Console.WriteLine($"You have {quarters} quarters, {dimes} dimes, {nickels} nickels, and {pennies} pennies, totalling {value.ToString("c")}  in your wallet.");
            Console.WriteLine("press any key to continue.");
            Console.ReadKey();

            return(value);
        }
Ejemplo n.º 30
0
        //public int quarterCount;
        public Wallet()
        {
            coins = new List <Coin>();
            //quarterCount = 1;
            Quarter quarter = new Quarter();

            PopulateDefaultWallet(10, quarter);

            Dime dime = new Dime();

            PopulateDefaultWallet(10, dime);

            Nickel nickel = new Nickel();

            PopulateDefaultWallet(10, nickel);

            Penny penny = new Penny();

            PopulateDefaultWallet(50, penny);
        }