Ejemplo n.º 1
0
        static void intTest()
        {
            var array = new ListOfArrayList <int>(4);

            array.Add(1);
            array.Add(3);
            array.Add(6);
            array.Add(2);

            array.Add(8);
            array.Add(0);
            array.Add(4);
            array.Add(7);

            array.Add(1);
            WriteLine("Aktualna tablica: ");
            WriteLine(array);
            WriteLine("Metoda Remove(3)");
            array.Remove(3);
            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda Trim()");
            array.Trim();
            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda array[7]: ");
            WriteLine(array[7]);

            WriteLine("Metoda Clear()");
            array.Clear();
            WriteLine("Aktualna tablica: ");
            WriteLine(array);
        }
Ejemplo n.º 2
0
        static void mixedNumberTest()
        {
            var array = new ListOfArrayList <MixedNumber>(3);

            MixedNumber myNumber = new MixedNumber(5.25);

            array.Add(myNumber);
            array.Add(new MixedNumber(43, 23));
            array.Add(new MixedNumber(10.25));
            array.Add(new MixedNumber(81, 2));

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda RemoveAt(2)");
            array.RemoveAt(2);

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda IndexOf(myNumber)");
            WriteLine(array.IndexOf(myNumber));

            WriteLine("Metoda Contains(myNumber)");
            WriteLine(array.Contains(myNumber));

            WriteLine("Metoda Trim()");
            array.Trim();

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda Remove(myNumber)");
            array.Remove(myNumber);

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Count");
            WriteLine(array.Count);

            WriteLine("Metoda Clear()");
            array.Clear();

            WriteLine("Aktualna tablica: ");
            WriteLine(array);
        }
Ejemplo n.º 3
0
        static void studentTest()
        {
            var array = new ListOfArrayList <Student>(1);

            Student ja = new Student("Kamil", "Graczyk", 246994, "*****@*****.**");

            array.Add(ja);
            array.Add(new Student("Jan", "Nowak", 249874, "*****@*****.**"));
            array.Add(new Student("Zigniew", "Kowalski", 247896, "*****@*****.**"));

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda RemoveAt(2)");
            array.RemoveAt(2);

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda IndexOf(new Student(\"Kamil\", \"Graczyk\", 246994, \"[email protected]\"))");
            WriteLine(array.IndexOf(new Student("Kamil", "Graczyk", 246994, "*****@*****.**")));

            WriteLine("Metoda Contains(new Student(\"Kamil\", \"Graczyk\", 246994, \"[email protected]\"))");
            WriteLine(array.Contains(new Student("Kamil", "Graczyk", 246994, "*****@*****.**")));

            WriteLine("Metoda Trim()");
            array.Trim();

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Metoda Remove(ja)");
            array.Remove(ja);

            WriteLine("Aktualna tablica: ");
            WriteLine(array);

            WriteLine("Count");
            WriteLine(array.Count);

            WriteLine("Metoda Clear()");
            array.Clear();

            WriteLine("Aktualna tablica: ");
            WriteLine(array);
        }
Ejemplo n.º 4
0
        //Zadanie 2

        public static ListOfArrayList <T> operator +(ListOfArrayList <T> arraysList, IEnumerable <T> collection)
        {
            ListOfArrayList <T> newListOfArrayList = new ListOfArrayList <T>(arraysList.arraySize);

            for (int i = 0; i < arraysList.Count; i++)
            {
                newListOfArrayList.Add(arraysList[i]);
            }

            IEnumerator <T> enumerator = collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                newListOfArrayList.Add(enumerator.Current);
            }

            return(newListOfArrayList);
        }
Ejemplo n.º 5
0
        static void stringTest()
        {
            var array = new ListOfArrayList <string>(2);

            array.Add("Ala");
            array.Add("ma");

            string kot = "kota";

            array.Add(kot);

            WriteLine("Aktualna tablica: ");
            WriteLine(array);
            WriteLine("Count: ");
            WriteLine(array.Count);

            WriteLine("Metoda Contains(kot): ");
            WriteLine(array.Contains(kot));
            WriteLine("Metoda IndexOf(kot): ");
            WriteLine(array.IndexOf(kot));
        }
Ejemplo n.º 6
0
        static void PresntMixedNumbersList()
        {
            ListOfArrayList <MixedNumber> mixedNumbers = new ListOfArrayList <MixedNumber>(3);

            mixedNumbers.Add(new MixedNumber(2, 3, 4));
            mixedNumbers.Add(new MixedNumber(1, 4, 3));
            mixedNumbers.Add(new MixedNumber(3, 1, 5));
            mixedNumbers.Add(new MixedNumber(2, 4, 7));
            mixedNumbers.Add(new MixedNumber(5, 2, 3));
            mixedNumbers.Add(new MixedNumber(1, 1, 3));
            mixedNumbers.Add(new MixedNumber(2, 5));

            WriteLine(mixedNumbers);

            WriteLine("\nContains MixedNumber(2, 3, 4)");
            WriteLine(mixedNumbers.Contains(new MixedNumber(2, 3, 4)));

            WriteLine("\nIndexOf MixedNumber(5, 2, 3)");
            WriteLine(mixedNumbers.IndexOf(new MixedNumber(5, 2, 3)));

            WriteLine("\nRemove MixedNumber(5, 2, 3)");
            mixedNumbers.Remove(new MixedNumber(5, 2, 3));
            WriteLine(mixedNumbers);

            WriteLine("\nRemoveAt(2)");
            mixedNumbers.RemoveAt(2);
            WriteLine(mixedNumbers);

            WriteLine("\nTrim");
            mixedNumbers.Trim();
            WriteLine(mixedNumbers);

            WriteLine("\noperator+");
            List <MixedNumber> antoherMixedNumbers = new List <MixedNumber> {
                new MixedNumber(1, 2, 3), new MixedNumber(3, 2, 5)
            };

            mixedNumbers = mixedNumbers + antoherMixedNumbers;
            WriteLine(mixedNumbers);
        }
Ejemplo n.º 7
0
        static void PresetnStudentsList()
        {
            ListOfArrayList <Student> students = new ListOfArrayList <Student>(3);

            students.Add(new Student("Kamil", "Nowak", 243422, "*****@*****.**"));
            students.Add(new Student("Jan", "Kowalski", 592912, "*****@*****.**"));
            students.Add(new Student("Paweł", "Nowak", 129394, "*****@*****.**"));
            students.Add(new Student("Andrzej", "Wiśniewski", 491921, "*****@*****.**"));

            WriteLine(students);

            WriteLine("\nContains (Kamil, Nowak, 243422, [email protected])");
            WriteLine(students.Contains(new Student("Kamil", "Nowak", 243422, "*****@*****.**")));

            WriteLine("\nIndexOf (Paweł, Nowak, 129394, [email protected])");
            WriteLine(students.IndexOf(new Student("Paweł", "Nowak", 129394, "*****@*****.**")));

            WriteLine("\nRemove (Jan, Kowalski, 592912, [email protected])");
            students.Remove(new Student("Jan", "Kowalski", 592912, "*****@*****.**"));
            WriteLine(students);

            WriteLine("\nRemoveAt(2)");
            students.RemoveAt(2);
            WriteLine(students);

            WriteLine("\nTrim");
            students.Trim();
            WriteLine(students);

            WriteLine("\noperator+");
            List <Student> antoherStudents = new List <Student> {
                new Student("Jan", "Kowalski", 246879, "*****@*****.**")
            };

            students = students + antoherStudents;
            WriteLine(students);
        }