예제 #1
0
파일: Program.cs 프로젝트: DaSchee/FA84_AS
        public string Select()
        {
            Pkw    tmp          = ersterPkw;
            string selectString = "";

            while (tmp != null)
            {
                selectString += tmp.GetMarke() + " " + tmp.GetModell() + " " + tmp.GetFarbe() + "\n";
                tmp           = tmp.GetNext();
            }
            return(selectString);
        }
예제 #2
0
파일: Program.cs 프로젝트: DaSchee/FA84_AS
        public void Delete(Pkw pkw)
        {
            Pkw  tmp           = ersterPkw;
            Pkw  previousEntry = null;
            bool deleted       = false;

            while (tmp != null)
            {
                if
                (
                    pkw.GetFarbe() == tmp.GetFarbe() &&
                    pkw.GetKmStand() == tmp.GetKmStand() &&
                    pkw.GetMarke() == tmp.GetMarke() &&
                    pkw.GetModell() == tmp.GetModell() &&
                    pkw.GetType() == tmp.GetType()
                )
                {
                    deleted = true;
                    if (tmp == ersterPkw)
                    {
                        ersterPkw = tmp.GetNext();
                        tmp       = null;
                        anzahlPkws--;
                    }
                    else if (tmp == letzterPkw && previousEntry == null)
                    {
                        tmp        = null;
                        letzterPkw = ersterPkw = null;
                        anzahlPkws = 0;
                    }
                    else
                    {
                        previousEntry.SetNext(tmp.GetNext());
                        tmp = null;
                        anzahlPkws--;
                    }
                    Console.WriteLine("Deletion Success");
                    Console.Write("\n");
                }
                else
                {
                    previousEntry = tmp;
                    tmp           = tmp.GetNext();
                }
            }
            if (deleted == false)
            {
                Console.Write("List doesn't contain the Object you wish to Delete \n");
            }
            Console.Write(Select());
        }