Пример #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;
            int selectedTable = Convert.ToInt32(comboBox.SelectedItem);

            Multiplication multi = new Multiplication();
            string timesTable = multi.FormatTable(multi.Generate(selectedTable));

            this.richTextBox1.Text = timesTable;
        }
Пример #2
0
        public void FormatTables()
        {
            Multiplication multiplication = new Multiplication();
            List<int[]> table = new List<int[]>();
            table.Add(new int[] { 0, 0, 0 });
            table.Add(new int[] { 0, 1, 0 });

            string formatedTable = multiplication.FormatTable(table);

            Assert.AreEqual("0 x 0 = 0\n0 x 1 = 0\n", formatedTable);
        }
Пример #3
0
        public void GeneratesTwoTimesTable()
        {
            Multiplication multiplication = new Multiplication();
            List<int[]> twoTimesTable = multiplication.Generate(2);

            List<int[]> expected = new List<int[]>();
            expected.Add(new int[] { 0, 0, 0 });
            expected.Add(new int[] { 0, 1, 0 });
            expected.Add(new int[] { 0, 2, 0 });
            expected.Add(new int[] { 1, 0, 0 });
            expected.Add(new int[] { 1, 1, 1 });
            expected.Add(new int[] { 1, 2, 2 });
            expected.Add(new int[] { 2, 0, 0 });
            expected.Add(new int[] { 2, 1, 2 });
            expected.Add(new int[] { 2, 2, 4 });

            Assert.AreEqual(expected, twoTimesTable);
        }
Пример #4
0
        public void GeneratesTwoTimesTable()
        {
            Multiplication multiplication = new Multiplication();
            List <int[]>   twoTimesTable  = multiplication.Generate(2);

            List <int[]> expected = new List <int[]>();

            expected.Add(new int[] { 0, 0, 0 });
            expected.Add(new int[] { 0, 1, 0 });
            expected.Add(new int[] { 0, 2, 0 });
            expected.Add(new int[] { 1, 0, 0 });
            expected.Add(new int[] { 1, 1, 1 });
            expected.Add(new int[] { 1, 2, 2 });
            expected.Add(new int[] { 2, 0, 0 });
            expected.Add(new int[] { 2, 1, 2 });
            expected.Add(new int[] { 2, 2, 4 });

            Assert.AreEqual(expected, twoTimesTable);
        }