예제 #1
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);
     }
 }
예제 #2
0
        //constructor
        public Wallet()
        {
            coins = new List <Coin>();
            Coin Nickle  = new Coin();
            Coin Dime    = new Coin();
            Coin Quarter = new Coin();

            for (int i = 0; i < 50; i++)
            {
                Penny penny = new Penny();
                coins.Add(penny);
            }
            for (int i = 0; i < 10; i++)
            {
                coins.Add(Nickle);
            }
            for (int i = 0; i < 20; i++)
            {
                coins.Add(Dime);
            }
            for (int i = 0; i < 8; i++)
            {
                coins.Add(Quarter);
            }
        }
예제 #3
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);
            }
        }
예제 #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);
        }
예제 #5
0
        public void FillRegister()
        {
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickle  nickle  = new Nickle();
            Penny   penny   = new Penny();

            for (int i = 0; i < 20; i++)
            {
                quarter = new Quarter();
                register.Add(quarter);
            }
            for (int i = 0; i < 10; i++)
            {
                dime = new Dime();
                register.Add(dime);
            }
            for (int i = 0; i < 20; i++)
            {
                nickle = new Nickle();
                register.Add(nickle);
            }
            for (int i = 0; i < 50; i++)
            {
                penny = new Penny();
                register.Add(penny);
            }
        }
예제 #6
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);
            }
        }
예제 #7
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);
        }
예제 #8
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);
            }
        }
예제 #9
0
        public List <Coin> ChooseCoins(Coin coin, string coinName)
        {
            List <Coin> coins = new List <Coin>();

            while (coinName != "stop")
            {
                if (coinName == "quarter")
                {
                    coin = new Quarter();
                    coins.Add(coin);
                }
                else if (coinName == "nickel")
                {
                    coin = new Nickle();
                    coins.Add(coin);
                }
                else if (coinName == "dime")
                {
                    coin = new Dime();
                    coins.Add(coin);
                }
                else if (coinName == "penny")
                {
                    coin = new Penny();
                    coins.Add(coin);
                }
            }
            return(coins);
        }
예제 #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);
            }
        }
예제 #11
0
        //member methods
        public void AddCoinstoWallet()
        {
            //create a for loop to add the coins
            for (int i = 0; i < 10; i++)
            {
                Penny penny = new Penny();
                coins.Add(penny);
            }

            for (int i = 0; i < 12; i++)
            {
                Quarter quarter = new Quarter();
                coins.Add(quarter);
            }

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

            for (int i = 0; i < 20; i++)
            {
                Nickle nickle = new Nickle();
                coins.Add(nickle);
            }
        }
예제 #12
0
 public SodaMachine()
 {
     register          = new List <Coin>();
     inventory         = new List <Can>();
     temporaryRegister = new List <Coin>();
     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++)
     {
         Nickle nickle = new Nickle();
         register.Add(nickle);
     }
     for (int i = 0; i < 50; i++)
     {
         Penny penny = new Penny();
         register.Add(penny);
     }
     for (int i = 0; i < 10; i++)
     {
         RootBeer   rootBeer   = new RootBeer();
         Cola       cola       = new Cola();
         OrangeSoda orangeSoda = new OrangeSoda();
         inventory.Add(cola);
         inventory.Add(rootBeer);
         inventory.Add(orangeSoda);
     }
 }
예제 #13
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);
            }
        }
예제 #14
0
        public Wallet()
        {
            coins = new List <Coin>();
            for (int index = 0; index < 16; index++)
            {
                Quarter quarter = new Quarter();
                coins.Add(quarter);
            }
            for (int index = 0; index < 10; index++)
            {
                Dime dime = new Dime();
                coins.Add(dime);
            }
            for (int index = 0; index < 10; index++)
            {
                Nickle nickle = new Nickle();
                coins.Add(nickle);
            }
            for (int index = 0; index < 50; index++)
            {
                Penny penny = new Penny();
                coins.Add(penny);
            }

            card = new Card();
        }
예제 #15
0
        static void Main(string[] args)
        {
            Coin   penny       = new Penny();
            double totalChange = 0;

            totalChange += penny.Value;

            List <int> numbers = new List <int>()
            {
                5, 4, 3, 2, 1
            };

            Console.WriteLine(numbers.Count);

            numbers.Count = 10;

            for (int i = 0; i < numbers.Count; i++)
            {
            }

            Console.WriteLine();
            UserInterface.DisplayOpeningMessage();

            Simulation simulation = new Simulation();

            simulation.;
        }
예제 #16
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);
        }
예제 #17
0
 private void StockPennies()
 {
     for (int i = 0; i < 50; i++)
     {
         Penny penny = new Penny();
         register.Add(penny);
     }
 }
예제 #18
0
 public void AddPennys()
 {
     for (int i = 0; i < 50; i++)
     {
         Penny addPennys = new Penny();
         PennyHolder.Add(addPennys);
     }
 }
예제 #19
0
 private void AddPenniesToRegister(int startingPennies)
 {
     for (int i = 0; i < startingPennies; i++)
     {
         Penny penny = new Penny();
         _register.Add(penny);
     }
 }
예제 #20
0
 private void AddPennies(int count)
 {
     for (int i = 0; i < count; i++)
     {
         Coin coin = new Penny();
         coins.Add(coin);
     }
 }
예제 #21
0
 public void AddPennyToCashBox(int numberOfPennies)
 {
     for (int i = 0; i < numberOfPennies; i++)
     {
         Penny penny = new Penny();
         pennies.Add(penny);
     }
 }
예제 #22
0
 private void AddPenniesToWallet(int startingPennies)
 {
     for (int i = 0; i < startingPennies; i++)
     {
         Penny penny = new Penny();
         Coins.Add(penny);
     }
 }
예제 #23
0
 public void AddPenniesToWallet()
 {
     for (int i = 0; i < 20; i++)
     {
         Penny penny = new Penny();
         coins.Add(penny);
     }
 }
 public void AddPennies()
 {
     Pennies = new List <Penny>();
     for (int i = 0; i < 50; i++)
     {
         Penny penny = new Penny();
         Pennies.Add(penny);
     }
 }
예제 #25
0
        //Member Methods (Can Do)
        //Fills wallet with starting money
        private void FillRegister()///use this space for loops for coins
        {
            Coin pennyInWallet = new Penny();

            Coins.Add(pennyInWallet);



            Console.WriteLine(pennyInWallet.Name + " with a value of: " + pennyInWallet.Value + " was generated from my wallet constructor ");
        }
예제 #26
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);
            }
        }
예제 #27
0
        public void PayInPennies()
        {
            Console.WriteLine("How many pennies are you putting in?");
            usersPenny = int.Parse(Console.ReadLine());

            for (int i = 0; i < usersPenny; i++)
            {
                Penny p = new Penny();
                userCoinPurse.Add(p);
            }
        }
예제 #28
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);
        }
예제 #29
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);
        }
예제 #30
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;
 }