Exemple #1
0
        public Form1()
        {
            // a^n b^n
            TabelkaStanow tabelka = new TabelkaStanow(3, 3, new List <Char> {
                '$', 'a', 'b'
            });

            tabelka.wklejStan(new List <int> {
                -1, 0, 1
            }, 0);
            tabelka.wklejStan(new List <int> {
                -1, -1, 1
            }, 1);
            tabelka.wklejStan(new List <int> {
                -2, -1, -1
            }, 2);

            TabelkaStanow tabelkaStos = new TabelkaStanow(3, 3, new List <Char> {
                '$', 'a', 'b'
            });

            tabelkaStos.wklejStan(new List <int> {
                0, 1, 2
            }, 0);
            tabelkaStos.wklejStan(new List <int> {
                0, 0, 2
            }, 1);
            tabelkaStos.wklejStan(new List <int> {
                0, 0, 0
            }, 2);

            TabelkaStos stos = new TabelkaStos(3, 3, new List <Char> {
                '#', 'a', 'b'
            });

            stos.wklejStan(new List <int> {
                0, 0, -1
            }, 0);
            stos.wklejStan(new List <int> {
                2, 1, -1
            }, 1);
            stos.wklejStan(new List <int> {
                2, -1, -1
            }, 2);

            automat = new Automat(tabelka, tabelkaStos, stos);
            automat.PrzypiszList(list);
            InitializeComponent();

            /*
             * DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
             * row.Cells[0].Value = -1;
             * row.Cells[1].Value = -1;
             * row.Cells[2].Value = -1;
             *
             * dataGridView1.Rows.Add(row);
             */
            for (int i = 0; i < tabelka.pobierzliczbaZnakow(); i++)
            {
                DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[i].Clone();
                for (int j = 0; j < tabelka.pobierzliczbaStanow(); j++)
                {
                    int symbol = tabelka.pobierzStan(i, j);
                    row.Cells[j].Value = (symbol == -1 ? "N" : (symbol == -2 ? "A" : symbol.ToString()));
                }
                row.HeaderCell.Value = tabelka.pobierzZnak(i).ToString();
                dataGridView1.Rows.Add(row);
            }

            for (int i = 0; i < tabelkaStos.pobierzliczbaZnakow(); i++)
            {
                DataGridViewRow row = (DataGridViewRow)dataGridView2.Rows[i].Clone();
                for (int j = 0; j < tabelkaStos.pobierzliczbaStanow(); j++)
                {
                    int symbol = tabelkaStos.pobierzStan(i, j);
                    row.Cells[j].Value = (symbol == -1 ? "N" : (symbol == -2 ? "A" : symbol.ToString()));
                }
                row.HeaderCell.Value = tabelkaStos.pobierzZnak(i).ToString();
                dataGridView2.Rows.Add(row);
            }

            for (int i = 0; i < stos.pobierzliczbaZnakow(); i++)
            {
                DataGridViewRow row = (DataGridViewRow)dataGridView3.Rows[i].Clone();
                for (int j = 0; j < stos.pobierzliczbaStanow(); j++)
                {
                    int symbol = stos.pobierzStan(i, j);
                    row.Cells[j].Value = (symbol == -1 ? "N" : (symbol == -2 ? "A" : symbol.ToString()));
                }
                row.HeaderCell.Value = stos.pobierzZnak(i).ToString();
                dataGridView3.Rows.Add(row);
            }
        }