예제 #1
0
        public void CheckHundredNumber()
        {
            // Arrange
            string expected = "two hundred and three";
            int    number   = 203;
            // Act
            string actual = NumberReader.GetNumberToString(number);

            // Assert
            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void CheckMixedHundredNumber()
        {
            // Arrange
            string expected = "four hundred and ten";
            int    number   = 410;
            // Act
            string actual = NumberReader.GetNumberToString(number);

            // Assert
            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        static void Main(string[] args)
        {
            int x = NumberReader <int> .ReadUntilNoResult("x", int.TryParse);

            WriteVariable(x);
            int y = NumberReader <int> .ReadOrDefault("y", int.TryParse);

            WriteVariable(y);
            int?z = NumberReader <int> .ReadOrNull("z", int.TryParse);

            WriteVariable(z);
        }
 private NumberReaderFactory()
 {
     //LoadImplmentationFromSource();
     // select the correct implementation for the language pack
     if ("it" == AudioPlayer.soundPackLanguage)
     {
         numberReader = new NumberReaderIt();
     }
     else
     {
         numberReader = new NumberReaderEn();
     }
 }
예제 #5
0
        static void Main(string[] args)
        {
            string lineRead = InputSystem.ReadLine();

            NumberReader numbersRead = new NumberReader(lineRead);

            double value_A = numbersRead.Read_A();
            double value_B = numbersRead.Read_B();
            double value_C = numbersRead.Read_C();

            Bhaskara formulaBhaskara = new Bhaskara(value_A, value_B, value_C);

            formulaBhaskara.Calculate();

            Console.ReadKey();
        }
예제 #6
0
        static void Main(string[] args)
        {
            List <bool> results = new List <bool>();

            string       lineRead    = InputSystem.ReadLine();
            NumberReader numbersRead = new NumberReader(lineRead);

            int num_A = numbersRead.Read_A();
            int num_B = numbersRead.Read_B();
            int num_C = numbersRead.Read_C();
            int num_D = numbersRead.Read_D();

            bool auxResult;

            auxResult = NumberChecker.IsNumberGreaterThanOtherNumber(num_B, num_C);
            results.Add(auxResult);

            auxResult = NumberChecker.IsNumberGreaterThanOtherNumber(num_D, num_A);
            results.Add(auxResult);

            int sumC_D = MathOperations.Sum(num_C, num_D);
            int sumA_B = MathOperations.Sum(num_A, num_B);

            auxResult = NumberChecker.IsNumberGreaterThanOtherNumber(sumC_D, sumA_B);
            results.Add(auxResult);

            auxResult = NumberChecker.IsNumberPositive(num_C);
            results.Add(auxResult);

            auxResult = NumberChecker.IsNumberPositive(num_D);
            results.Add(auxResult);

            auxResult = NumberChecker.IsNumberEven(num_A);
            results.Add(auxResult);

            CheckResults.CheckIfAllResultsAreTrue(results);

            Console.ReadKey();
        }
예제 #7
0
 public MainPageModel()
 {
     Word         = "";
     numberReader = new NumberReader();
 }
예제 #8
0
        private string BuildData1HD(string MT32ID)
        {
            string     Data = "";
            List <Inv> lInv = new List <Inv>();

            DataRow[] ldrMT = dtInvoices.Select("MT32ID='" + MT32ID + "'");
            if (ldrMT.Length == 0)
            {
                return(Data);
            }
            DataRow drMT = ldrMT[0];

            Invoice invoice = new Invoice();

            invoice.ArisingDate    = DateTime.Parse(drMT["NgayCT"].ToString());
            invoice.CusCode        = drMT["MaKH"].ToString();
            invoice.CusName        = drMT["TenKH"].ToString();
            invoice.CusTaxCode     = drMT["MST"].ToString();
            invoice.CusAddress     = drMT["DiaChi"].ToString();
            invoice.CusBankNo      = drMT["TkNganHang"].ToString();
            invoice.CusBankName    = drMT["NganHang"].ToString();
            invoice.CusPhone       = drMT["SDT"].ToString();
            invoice.EmailDeliver   = drMT["Email"].ToString();
            invoice.Buyer          = drMT["Ongba"].ToString();
            invoice.SellBankNo     = "";
            invoice.InvNote        = drMT["Diengiai"].ToString();;
            invoice.PaymentMethod  = drMT["TenHTTT"].ToString();
            invoice.Currency       = drMT["MaNT"].ToString();
            invoice.ExRate         = double.Parse(drMT["TyGia"].ToString());
            invoice.Amount         = double.Parse(drMT["TTienH"].ToString());
            invoice.DiscountAmount = double.Parse(drMT["TCK"].ToString());
            if (drMT["MaThue"].ToString() == "KT")
            {
                invoice.VATRate = 0;
            }
            else
            {
                invoice.VATRate = double.Parse(drMT["MaThue"].ToString());
            }
            invoice.VATAmount     = double.Parse(drMT["TThue"].ToString());
            invoice.Total         = double.Parse(drMT["TTien"].ToString());
            invoice.AmountInWords = NumberReader.ReadMoney(double.Parse(drMT["TTien"].ToString()).ToString("###############0")) + "  đồng";
            DataRow[]      ldrdt = dtDetails.Select("MT32ID='" + drMT["MT32ID"].ToString() + "'");
            List <Product> lpro  = new List <Product>();

            for (int i = 0; i < ldrdt.Length; i++)
            {
                DataRow dr  = ldrdt[i];
                Product pro = new Product();
                pro.No             = i;
                pro.ProdCode       = dr["MaVT"].ToString();
                pro.ProdName       = dr["TenVT"].ToString();
                pro.ProdUnit       = dr["TenDVT"].ToString();
                pro.ProdQuantity   = double.Parse(dr["Soluong"].ToString());
                pro.ProdPrice      = double.Parse(dr["Gia"].ToString());
                pro.Amount         = double.Parse(dr["ps"].ToString());
                pro.ProdVat        = double.Parse(dr["Thuesuat"].ToString());
                pro.ProdVATAmount  = double.Parse(dr["thue"].ToString());
                pro.DiscountRate   = double.Parse(dr["tileck"].ToString());
                pro.DiscountAmount = double.Parse(dr["ck"].ToString());
                if (double.Parse(dr["ps"].ToString()) == 0)
                {
                    pro.Promotion = 1;
                }
                else
                {
                    pro.Promotion = 0;
                }
                lpro.Add(pro);
            }
            invoice.Products = lpro.ToArray();
            Inv inv = new Inv();

            inv.key     = drMT["MT32ID"].ToString();
            inv.Invoice = invoice;
            lInv.Add(inv);

            invoices = lInv.ToArray();
            StringWriter stringwriter = new System.IO.StringWriter();

            XmlSerializer           serializer = new XmlSerializer(invoices.GetType());
            XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();

            ns.Add("", "");

            // serializer.Serialize(stringwriter, invoices,ns);
            serializer.Serialize(stringwriter, invoices);

            string xmlInvData = stringwriter.ToString();

            string[] lines = xmlInvData.Split("\n".ToCharArray()).Skip(2).ToArray();
            Data = string.Join("\n", lines);
            Data = "<Invoices>\n" + Data.Replace("</ArrayOfInv>", "</Invoices>");
            return(Data);
        }
예제 #9
0
        /// <summary>
        /// Return parsed formula nodes without RPN
        /// </summary>
        public List <BaseFormulaNode> ParseWithoutRpn(ReadOnlySpan <char> formula)
        {
            var negativeBracketCounters = new BracketCounters();
            var nodes = new List <BaseFormulaNode>();

            for (int i = 0; i < formula.Length; i++)
            {
                var ch = formula[i];

                if (ch.IsWhiteSpace())
                {
                    continue;
                }

                if (FunctionCharReader.TryProceedFunctionChar(nodes, ch))
                {
                    continue;
                }

                if (BracketReader.TryProceedOpenBracket(nodes, formula, negativeBracketCounters, ref i))
                {
                    continue;
                }

                if (BracketReader.TryProceedCloseBracket(nodes, formula, negativeBracketCounters, ref i))
                {
                    continue;
                }

                if (VariableReader.TryProceedBorderedVariable(nodes, formula, ref i))
                {
                    continue;
                }

                if (NumberReader.TryProceedNumber(nodes, formula, ref i))
                {
                    continue;
                }

                if (FunctionsReader.TryProceedFunction(nodes, formula, ref i))
                {
                    continue;
                }

                if (VariableReader.TryProceedSimpleVariable(nodes, formula, ref i))
                {
                    continue;
                }

                if (WordReader.TryProceedWord(nodes, formula, ref i))
                {
                    continue;
                }

                if (ListReader.TryProceedList(nodes, formula, ref i))
                {
                    continue;
                }

                if (OperatorReader.TryProceedOperator(nodes, formula, ref i))
                {
                    continue;
                }
            }

            return(nodes);
        }
예제 #10
0
        public void InputValid_WhenPassedInput_ShouldReturnValid([Values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)] int input)
        {
            string output = NumberReader.IsValidNumber(input);

            Assert.AreEqual("Valid", output);
        }
예제 #11
0
        public void InputInvalid_WhenPassedInput_ShouldReturnInvalid([Values(11, 12, 13, 14, 0, -1, -2)] int input)
        {
            string output = NumberReader.IsValidNumber(input);

            Assert.AreEqual("Invalid", output);
        }