Ejemplo n.º 1
0
    static void Main()
    {
        //giving CoinPurse a reference
        CoinPurse myCoinPurse = new CoinPurse();

        //showing that we have nothing in the coin purse
        Console.WriteLine("we have nothing in the coin purse: {0:f2}", myCoinPurse.totalCoins());
        //adding 3 pennies into the coin purse
        myCoinPurse.addPennies(3);
        //showing the resulting amount of money in the coin purse
        Console.WriteLine("here we added three pennies; {0:f2}", myCoinPurse.totalCoins());
        //adding 4 nickles into the coin purse
        myCoinPurse.addNickles(4);
        //showing that we added 4 nickles into the coin purse
        Console.WriteLine("here we add four nickles on top of the three pennies: {0:f2}", myCoinPurse.totalCoins());
        //adding 2 dimes into the coin purse
        myCoinPurse.addDimes(2);
        //showing that we added 2 coins into the purse
        Console.WriteLine("here are the two added dimes: {0:f2}", myCoinPurse.totalCoins());
        //adding a quarter
        myCoinPurse.addQuarters(1);
        //showing that we added the quarter
        Console.WriteLine("here we add a quarter: {0:f2}", myCoinPurse.totalCoins());
        //taking 20 cents out of the total in the coin purse
        myCoinPurse.takeDimes(2);
        //showing that we took 20 cents out of the coin purse
        Console.WriteLine("here we take two dimes out, or twenty cents. {0:f2}", myCoinPurse.totalCoins());
        myCoinPurse.emptyCoins(0);
        Console.WriteLine("here we empty the coin purse into something less \nfeminine like a satchel or a batman piggy bank: {0}", myCoinPurse.totalCoins());
        myCoinPurse.addQuarters(5);
        Console.WriteLine("{0}", myCoinPurse.totalCoins());
        Console.ReadLine();
    } //end main