D
D
deadspace122020-04-21 16:34:57
C++ / C#
deadspace12, 2020-04-21 16:34:57

How to display response in listbox?

according to the assignment, I enter the text into the textbox and find it in the array,
I need to somehow display the method in the listbox, but I don’t know how I
use abstract classes
here is my code

public spisok()
        {
            InitializeComponent();
            string[] cars =  { "FIAT, Opel, Mersedez, Shevrolet" };
            string[] FIOs =  { "Шурко, Замарев, Шульга, Чиженков" };
            listBox1.Items.AddRange(cars);
            listBox1.Items.AddRange(FIOs);
        }
        abstract class Poisk
        {
            public abstract string car();
            public abstract string FIO();
        }
        class Uchet : Poisk
        {
            string[] cars = {""};
            string[] FIOs = {""};
            string c = "";
            string f = "";
            public Uchet(string[] cars, string[] FIOs, string c, string f)
            {
                this.cars = cars; this.FIOs = FIOs; this.c = c; this.f = f;
            }
            public override string[] car()
            {
                if (cars.Intersect(c.Split()).Any())
                {
                    MessageBox.Show("машина содержится в списке");
                    
                }
                return cars;
            }
            public override string[] FIO()
            {
                if (FIOs.Intersect(f.Split()).Any())
                {
                    MessageBox.Show("водитель содержится в списке");

                }
                return FIOs;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string c = Convert.ToString(textBox1.Text);
            string f = Convert.ToString(textBox2.Text);
            Poisk f1;
            f1 = new Uchet(cars,FIOs,c,f);
            f1.car();
            f1.FIO();

            
        }
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question