Beispiel #1
0
        private void SEARCHbtn_Click(object sender, EventArgs e)
        {
            switch (SelectedDS)
            {
            case "DLL":
                if (searchprice == null)
                {
                    MessageBox.Show("Please input the price.");
                }
                else
                {
                    int keyPrice = int.Parse(searchprice.Text);
                    if (carListDLL.Search(keyPrice) == null)
                    {
                        searchresult.Text = "Can not find car with the key price!";
                    }
                    else
                    {
                        searchresult.Text = carListDLL.Search(keyPrice).car.Print();
                    }
                }
                break;

            case "Que":
                if (searchprice == null)
                {
                    MessageBox.Show("Please input the price.");
                }
                else
                {
                    int keyPrice = int.Parse(searchprice.Text);
                    if (carListQue.Search(keyPrice) == null)
                    {
                        searchresult.Text = "Can not find car with the key price!";
                    }
                    else
                    {
                        searchresult.Text = carListQue.Search(keyPrice).car.Print();
                    }
                }
                break;

            case "MH":
                MessageBox.Show("By using Max-Heap, here only show the most expensive car in the list.");
                searchresult.Text = carListMH.Print();
                break;

            case "BST":
                if (searchprice == null)
                {
                    MessageBox.Show("Please input the price.");
                }
                else
                {
                    int keyPrice = int.Parse(searchprice.Text);
                    if (carListBST.Search(keyPrice) == null)
                    {
                        searchresult.Text = "Can not find car with the key price!";
                    }
                    else
                    {
                        searchresult.Text = carListBST.Search(keyPrice).car.Print();
                    }
                }
                break;

            default:
                break;
            }
        }
Beispiel #2
0
 public Node Search(int key)
 {
     return(dll.Search(key));
 }