예제 #1
0
 public static void sorter(Tribune[] tabell, Sammenligner Sml)
 {
     Console.Write("\t");
     for (int i = 0; i < tabell.Length; i++)
     {
         Console.Write(tabell[i].visNavn());
         if (i < tabell.Length - 1)
         {
             Console.Write("  |  ");
         }
     }
     for (int i = 0; i < tabell.Length; i++)
     {
         for (int j = 0; j < tabell.Length - 1; j++)
         {
             if (Sml(tabell[j], tabell[j + 1]))
             {
                 bytt(tabell, j, j + 1);
             }
         }
     }
     Console.WriteLine("\n  -> Liste etter sortering:");
     Console.Write("\t");
     for (int i = 0; i < tabell.Length; i++)
     {
         Console.Write(tabell[i].visNavn());
         if (i < tabell.Length - 1)
         {
             Console.Write("  |  ");
         }
     }
     Console.WriteLine();
 }
예제 #2
0
        public void sorterTabellenEtterNavn(Tribune[] t)
        {
            Console.WriteLine("***Sortering etter Tribunenavn***");
            Console.WriteLine("  -> Listen før sortering: ");
            Sammenligner sml = new Sammenligner(minSorteringEtterNavn);

            sorter(t, sml);
        }
예제 #3
0
        public void SorterTabellEtterNavn(Tribune[] t)
        {
            Console.WriteLine("Sortering etter tribunenavn: ");
            Console.WriteLine(" -> Listen før sortering: ");
            Sammenligner sml = SorteringEtterNavn;

            Sorter(t, sml);
        }
예제 #4
0
파일: Sortering.cs 프로젝트: MrFS/CSharpOv5
 public static void sorter(object[] tab, Sammenligner Sml)
 {
     for (int i = 0; i < tab.Length; i++)
     {
         for (int j = 0; j < tab.Length - 1; j++)
         {
             if (Sml(tab[j], tab[j + 1]))
             {
                 bytt(tab, j, j + 1);
             }
         }
     }
 }
예제 #5
0
        public void sorterTabellenEtterInntekt(Tribune[] t)
        {
            Console.WriteLine("***Sortering etter hvor mye solgt for***");
            Console.WriteLine("  -> Listen før sortering: ");
            Sammenligner sml = new Sammenligner(minSorteringEtterInntekt);

            sorter(t, sml);
            Console.Write("  -> Bevis:\n\t");
            for (int i = 0; i < t.Length; i++)
            {
                Console.Write(t[i].Navn + ": " + t[i].SolgtFor() + ",-");
                if (i < t.Length - 1)
                {
                    Console.Write("  | ");
                }
            }
        }
예제 #6
0
        public void SorterTabellEtterInntekt(Tribune[] t)
        {
            Console.WriteLine("Sortering etter inntekt: ");
            Console.WriteLine(" -> Liste før sortering: ");
            Sammenligner sml = SorteringEtterInntekt;

            Sorter(t, sml);

            Console.WriteLine("Bevis for korrekt sortering: \n\t");
            for (int i = 0; i < t.Length; i++)
            {
                Console.WriteLine(t[i].VisNavn() + ": " + t[i].SolgtFor() + ",-");
                if (i < t.Length - 1)
                {
                    Console.WriteLine(" | ");
                }
            }
        }