Esempio n. 1
0
        private void convertRBTN_Click(object sender, EventArgs e)
        {
            int Roman;

            Roman           = RomanToArabic.RomanConverter(inRomanNumTB.Text);
            outRomanLB.Text = Roman.ToString();
        }
Esempio n. 2
0
 public static string ToRoman(int number)
 {
     if (number <= Roman.Max)
     {
         return(Roman.ToString(number));
     }
     throw new FormatException("Nombre supérieur à 4999");
 }
Esempio n. 3
0
 public void RomanToString()
 {
     Assert.AreEqual(Roman.ToString(1), "I");
     Assert.AreEqual(Roman.ToString(7), "VII");
     Assert.AreEqual(Roman.ToString(10), "X");
     Assert.AreEqual(Roman.ToString(123), "CXXIII");
     Assert.AreEqual(Roman.ToString(1234), "MCCXXXIV");
     Assert.AreEqual(Roman.ToString(4999), "MMMMCMXCIX");
     Assert.Pass("Passing test");
 }
Esempio n. 4
0
        public void ExceptionRoman()
        {
            Exception exception;

            exception = Assert.Throws <FormatException>(() => Roman.ToString(-1));
            Assert.AreEqual("Doit être compris entre 1 et 4999", exception.Message);
            exception = Assert.Throws <FormatException>(() => Roman.ToString(0));
            Assert.AreEqual("Doit être compris entre 1 et 4999", exception.Message);
            exception = Assert.Throws <FormatException>(() => Roman.ToString(5000));
            Assert.AreEqual("Doit être compris entre 1 et 4999", exception.Message);
            Assert.Pass("Passing test");
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string Hexdecimal;
                string Bin;
                string Arabic;
                int    Roman;
                string Roman2Bin;
                string Bin2Roman;
                string Ara2Hex;
                string Hex2Ara;
                string Ara2Bin;
                string Bin2Ara;
                string Hex2Roman;
                string Roman2Hex;

                if (numericTypeEntryCB.SelectedItem.Equals("Roman Numerals") &&
                    numericTypeResultCB.SelectedItem.Equals("Arabic"))

                {
                    Roman             = Roman_Arabic.RomanToArabic(numberTB.Text);
                    resultOutput.Text = Roman.ToString();
                }


                else if (numericTypeEntryCB.SelectedItem.Equals("Arabic") &&
                         numericTypeResultCB.SelectedItem.Equals("Roman Numerals"))

                {
                    Arabic            = Arabic_Roman.ArabicToRoman(int.Parse(numberTB.Text));
                    resultOutput.Text = Arabic.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Binary") &&
                         numericTypeResultCB.SelectedItem.Equals("Hexadecimal"))
                {
                    Bin = Bin_Hex.BinaryToHexadecimal((numberTB.Text));
                    resultOutput.Text = Bin.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Hexadecimal") &&
                         numericTypeResultCB.SelectedItem.Equals("Binary"))
                {
                    Hexdecimal        = Hex_Bin.HexadecimalToBinary((numberTB.Text));
                    resultOutput.Text = Hexdecimal.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Roman Numerals") &&
                         numericTypeResultCB.SelectedItem.Equals("Binary"))
                {
                    Roman2Bin         = Roman_Bin.RomanToBinary((numberTB.Text));
                    resultOutput.Text = Roman2Bin.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Binary") &&
                         numericTypeResultCB.SelectedItem.Equals("Roman Numerals"))
                {
                    Bin2Roman         = Bin_Roman.BinaryToRoman(int.Parse(numberTB.Text));
                    resultOutput.Text = Bin2Roman.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Arabic") &&
                         numericTypeResultCB.SelectedItem.Equals("Hexadecimal"))
                {
                    Ara2Hex           = Arabic_Hex.ArabicToHexadecimal((numberTB.Text));
                    resultOutput.Text = Ara2Hex.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Hexadecimal") &&
                         numericTypeResultCB.SelectedItem.Equals("Arabic"))
                {
                    Hex2Ara           = Hex_Arabic.HexadecimalToArabic((numberTB.Text));
                    resultOutput.Text = Hex2Ara.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Arabic") &&
                         numericTypeResultCB.SelectedItem.Equals("Binary"))
                {
                    Ara2Bin           = Arabic_Bin.ArabicToBinary((int.Parse(numberTB.Text)));
                    resultOutput.Text = Ara2Bin.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Binary") &&
                         numericTypeResultCB.SelectedItem.Equals("Arabic"))
                {
                    Bin2Ara           = Bin_Arabic.BinaryToArabic((numberTB.Text));
                    resultOutput.Text = Bin2Ara.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Hexadecimal") &&
                         numericTypeResultCB.SelectedItem.Equals("Roman Numerals"))
                {
                    Hex2Roman         = Hex_Roman.HexToRoman((numberTB.Text));
                    resultOutput.Text = Hex2Roman.ToString();
                }

                else if (numericTypeEntryCB.SelectedItem.Equals("Roman Numerals") &&
                         numericTypeResultCB.SelectedItem.Equals("Hexadecimal"))
                {
                    Roman2Hex         = Roman_Hex.RomanToHexadecimal((numberTB.Text));
                    resultOutput.Text = Roman2Hex.ToUpper();
                }

                else if (numericTypeEntryCB.SelectedItem == numericTypeResultCB.SelectedItem)
                {
                    resultOutput.Text = numberTB.Text;
                }

                else
                {
                    MessageBox.Show("You messed up dude.");
                };
            }

            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }