ICoin ConvertStringToICoin(string str)
        {
            switch (str)
            {
            case "Penny":
                ICoin p = new Penny();
                return(p);

            case "Nickel":
                ICoin n = new Nickel();
                return(n);

            case "Dime":
                ICoin d = new Dime();
                return(d);

            case "Quarter":
                ICoin q = new Quarter();
                return(q);

            case "Dollar Coin":
                ICoin dc = new DollarCoin();
                return(dc);

            default:
                return(null);
            }
        }
Exemplo n.º 2
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);
        }
        public void TestCoinValue()
        {
            CurrencyRepo  repo = new CurrencyRepo();
            ViewModelRepo vm   = new ViewModelRepo(repo);

            string defaultValue = vm.CoinValue; //get start count

            ICoin quarter = new Quarter();      //make and add quarter

            repo.AddCoin(quarter);

            string valueAfterQuarter = vm.CoinValue;//get count after adding quarter

            ICoin penny  = new Penny();
            ICoin dollar = new DollarCoin();
            ICoin nickel = new Nickel();
            ICoin dime   = new Dime();

            repo.AddCoin(penny);
            repo.AddCoin(dollar);
            repo.AddCoin(nickel);
            repo.AddCoin(dime);

            string valueAfterOneOfEachCoin = vm.CoinValue;

            Assert.AreEqual("Repo Value: 0", defaultValue);
            Assert.AreEqual("Repo Value: 0.25", valueAfterQuarter);
            Assert.AreEqual("Repo Value: 1.41", valueAfterOneOfEachCoin);
        }
        private void LoadCommand()
        {
            SerializableCurrencyRepo loadedRepo = null;

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt = ".bs";
            dialog.Filter     = $"{StaticInformation.FileExtensionName} Files (*{StaticInformation.FileExtension})|*{StaticInformation.FileExtension}";

            Nullable <bool> result = dialog.ShowDialog();

            if (result == true)
            {
                string filename = dialog.FileName;
                loadedRepo = SaveAndLoadUtility.Load <SerializableCurrencyRepo>(filename);

                USCurrencyRepo repo  = new USCurrencyRepo();
                List <ICoin>   coins = new List <ICoin>();
                foreach (SerializableCoin coin in loadedRepo.Coins)
                {
                    USCoin usCoin;
                    string name = coin.Name.Replace("US ", "");
                    switch (name)
                    {
                    case "Penny":
                        usCoin = new Penny();
                        break;

                    case "Nickel":
                        usCoin = new Nickel();
                        break;

                    case "Dime":
                        usCoin = new Dime();
                        break;

                    case "Quarter":
                        usCoin = new Quarter();
                        break;

                    case "Half Dollar":
                        usCoin = new HalfDollar();
                        break;

                    case "Dollar Coin":
                        usCoin = new DollarCoin();
                        break;

                    default:
                        usCoin = new Penny();
                        break;
                    }

                    coins.Add(usCoin);
                }

                StaticInformation.MainRepo.Coins = coins;
                RefreshAll();
            }
        }
Exemplo n.º 5
0
        public string GetRoublesString()
        {
            StringBuilder sb = new StringBuilder(Penny.ToString());

            if (sb.Length > 2)
            {
                if (sb.ToString(sb.Length - 2, 2) == "00")
                {
                    sb.Remove(sb.Length - 2, 2);
                }

                else
                {
                    sb.Insert(sb.Length - 2, ".");
                }
            }
            else if (sb.Length == 2)
            {
                sb.Insert(0, "0.");
            }
            else
            {
                sb.Insert(0, "0.0");
            }

            return(sb.ToString());
        }
        public void TestCoinCount()
        {
            CurrencyRepo  repo = new CurrencyRepo();
            ViewModelRepo vm   = new ViewModelRepo(repo);

            string defaultCount = vm.CoinCount; //get start count

            ICoin quarter = new Quarter();      //make and add quarter

            repo.AddCoin(quarter);

            string countAfterOneCoin = vm.CoinCount;//get count after adding quarter

            ICoin penny  = new Penny();
            ICoin dollar = new DollarCoin();
            ICoin nickel = new Nickel();
            ICoin dime   = new Dime();

            repo.AddCoin(penny);
            repo.AddCoin(dollar);
            repo.AddCoin(nickel);
            repo.AddCoin(dime);

            string countAfterOneOfEachCoin = vm.CoinCount;

            Assert.AreEqual("Coins: 0", defaultCount);
            Assert.AreEqual("Coins: 1", countAfterOneCoin);
            Assert.AreEqual("Coins: 5", countAfterOneOfEachCoin);
        }
Exemplo n.º 7
0
        public void PennyTest()
        {
            ICurrency penny = new Penny();

            Assert.AreEqual(0.01m, penny.Value);
            Assert.AreEqual("Penny", penny.Name);
        }
        public void SaveableCurrenyRepo_Saving_Load()
        {
            List <ICoin> RepoCoins()
            {
                ICoin p  = new Penny();
                ICoin h  = new HalfDollar();
                ICoin dc = new DollarCoin();
                ICoin q  = new Quarter();
                ICoin d  = new Dime();
                ICoin n  = new Nickel();

                List <ICoin> Repo_list = new List <ICoin>
                {
                    { p }
                };

                return(Repo_list);
            }

            //Arrange
            List <ICoin> loadedCoins;

            loadedCoins = RepoCoins();

            //Act
            repo.Save(loadedCoins);
            repo.Load();


            //Assert
            Assert.AreEqual(repo.Coins.Count, loadedCoins.Count);

            CollectionAssert.AreEqual(repo.Coins, loadedCoins);
        }
Exemplo n.º 9
0
 public void USPennyMonetaryValue()
 {
     //Arrange
     //Act
     p = new Penny();
     //Assert
     Assert.AreEqual(0.01, p.MonetaryValue);
 }
Exemplo n.º 10
0
        public void PennyMonetaryValue()
        {
            //Arrange
            p = new Penny();
            //Act

            //Assert
            Assert.AreEqual(.01, p.MonetaryValue);
        }
Exemplo n.º 11
0
        public void USCoinPennyAbout()
        {
            //Arrange
            p = new Penny();
            //Act

            //Assert
            Assert.AreEqual("US Penny is from 2018. It is worth $0.01. It was made in Philadelphia.", p.About());
        }
Exemplo n.º 12
0
 public void USCoinPennyMonetaryValue()
 {
     //Arrange
     p = new Penny();
     //Act
     //nothing should have .01;
     //Assert
     Assert.AreEqual(.01, p.MonetaryValue);
 }
Exemplo n.º 13
0
        public void USCoinPennyAbout()
        {
            //Arrange
            penny = new Penny();
            //Act

            //Assert
            Assert.AreEqual("US Penny is from 2017. It is worth $0.01. It was made in Denver.", penny.About());
        }
Exemplo n.º 14
0
 public USCurrencyRepoTest()
 {
     repo       = new CurrencyRepo();
     penny      = new Penny();
     nickel     = new Nickel();
     dime       = new Dime();
     quarter    = new Quarter();
     dollarCoin = new DollarCoin();
 }
Exemplo n.º 15
0
        public void PennyAbout()
        {
            //Arrange
            Penny p;

            //Act
            p = new Penny();
            //Assert
            //About output "US Penny is from 2017. It is worth $0.01. It was made in Denver"
        }
        public void CointIsAICoin()
        {
            //Arrange
            Coin coin = new Penny(); //Do I need an subclass to test this?

            //Act

            //Assert
            Assert.IsInstanceOfType(coin, typeof(ICoin));
        }
Exemplo n.º 17
0
        public void PennyMonetaryValueTest()
        {
            //Arrange
            Penny coin;

            //Act
            coin = new Penny();
            //Assert
            Assert.AreEqual(coin.MonetaryValue, .01);
        }
        public void USCoinPennyAbout()
        {
            //Arrange
            Penny p;

            //Act
            p = new Penny();
            //Assert
            Assert.AreEqual($"US Penny is from {System.DateTime.Now.Year}. It is worth {p.MonetaryValue:c}. It was made in Denver", p.About());
        }
Exemplo n.º 19
0
        public void USCoinPennyAbout()
        {
            //Arrange
            p = new Penny();

            //Act

            //Assert
            Assert.AreEqual($"Penny is from {DateTime.Now.Year.ToString()}. It is worth 0.01. It was made in Denver", p.About());
        }
Exemplo n.º 20
0
        public void CurrencyValueTests()
        {
            ICurrency penny  = new Penny();
            ICurrency dime   = new Dime();
            ICurrency dollar = new Dollar();

            Assert.AreEqual(.01m, penny.Value);
            Assert.AreEqual(.10m, dime.Value);
            Assert.AreEqual(1m, dollar.Value);
        }
        public void USCoinPennyMonetaryValue()
        {
            //Arrange
            Penny p;

            //Act
            p = new Penny();
            //Assert
            Assert.AreEqual(.01, p.MonetaryValue);
        }
Exemplo n.º 22
0
        public void USPennyConstructor()
        {
            //Arrange
            p = new Penny();
            //Act

            //Assert
            Assert.AreEqual(CurrencyLibrary.USCurrency.USCoinMintMark.P, p.MintMark);
            Assert.AreEqual(System.DateTime.Now.Year, p.Year); //Current year is default year
        }
Exemplo n.º 23
0
        public void USCoinPennyConstructor()
        {
            //Arrange
            p = new Penny();
            //Act

            //Assert
            Assert.AreEqual(USCoinMintMark.D, p.MintMark);     //D is the default mint mark
            Assert.AreEqual(System.DateTime.Now.Year, p.Year); //Current year is default year
        }
Exemplo n.º 24
0
        public void PennyAbout()
        {
            //Arrange
            Penny p;

            //Act
            p = new Penny();
            //Assert
            Assert.AreEqual("US Penny is from 2019. It is worth $0.01. It was made in Denver", p.About());
        }
 public override void HandleRequest(Penny penny, Client client)
 {
     if (penny.Weight == 23 && penny.Diameter == 4)
     {
         client.Sum += 50;
     }
     else if (Successor != null)
     {
         Successor.HandleRequest(penny, client);
     }
 }
        public void PennyMonetaryValue()
        {
            //Arrange
            double pennyValue = .01;

            //Go ahead try a double
            //Act
            p = new Penny();
            //Assert
            Assert.AreEqual(pennyValue, p.MonetaryValue);
        }
Exemplo n.º 27
0
 public static Penny getPenny()
 {
     lock (typeof(Penny))
     {
         if (theSingleton == null)
         {
             theSingleton = new Penny();
         }
     }
     return(theSingleton);
 }
        public void PennyAbout()
        {
            //Arrange

            double pennyValue = .01f;

            //Act
            p = new Penny();
            //Assert
            Assert.AreEqual($"US Penny is from {System.DateTime.Now.Year}. It is worth {pennyValue:c}. It was made in Denver", p.About());
        }
        private void ButtonAddCoin_Click(object sender, RoutedEventArgs e)
        {
            Coin tempC = new Penny();

            switch (CoinList.SelectionBoxItem)
            {
            case "Penny":
            {
                tempC = new Penny();
                break;
            }

            case "Nickel":
            {
                tempC = new Nickel();
                break;
            }

            case "Dime":
            {
                tempC = new Dime();
                break;
            }

            case "Quarter":
            {
                tempC = new Quarter();
                break;
            }

            case "Half Dollar":
            {
                tempC = new HalfDollar();
                break;
            }

            case "Dollar Coin":
            {
                tempC = new DollarCoin();
                break;
            }
            }

            repo.AddCoin(tempC);


            ViewModelRepo    = new ViewModelCreateCurrencyRepo(repo);
            this.DataContext = ViewModelRepo;

            string value = Convert.ToString(repo.TotalValue());

            labelRepoValueDisplay.Content = "$" + value;
        }
Exemplo n.º 30
0
        public void PennyAboutTest()
        {
            //Arrange
            Penny coin;

            //Act
            coin = new Penny();
            string expectedOutput = "US Penny is from 2017. It is worth $0.01. It was made in Denver.";

            //Assert
            Assert.AreEqual(coin.About(), expectedOutput);
        }