예제 #1
0
        static void Main(string[] args)
        {
            SimpleQueue <Angajat> listaAngajati = new SimpleQueue <Angajat>();

            List <Angajat> angajati = FileManager.GetAngajati();

            foreach (var angajat in angajati)
            {
                listaAngajati.Add(angajat);
            }
            listaAngajati.SortByName <Angajat>(); // metoda sorteaza in functie de nume
            FileManager.Output(listaAngajati, @"C:\Users\ALIN\source\repos\Clasa-Angajat\outputByName.txt");
            listaAngajati.Sort <Angajat>();       // metoda sorteaza in functie de vechime (masurata in luni)
            FileManager.Output(listaAngajati, @"C:\Users\ALIN\source\repos\Clasa-Angajat\outputBySeniority.txt");
        }
예제 #2
0
        private static string[] GetAngajatiInLines(SimpleQueue <Angajat> listaAngajati)
        {
            StringBuilder[] lines = new StringBuilder[listaAngajati.Count];
            for (int i = 0; i < lines.Length; i++)
            {
                lines[i] = new StringBuilder();
            }

            Angajat[] angajati = listaAngajati.RetrieveAll();
            for (int i = 0; i < angajati.Length; i++)
            {
                lines[i].Append(angajati[i].Nume + " " + angajati[i].Prenume + "  |   " + GetLuna(angajati[i].Vechime) + " Luni " + "si " + GetAn(angajati[i].Vechime) + " Ani");
            }

            string[] linesString = new string[listaAngajati.Count];
            for (int i = 0; i < linesString.Length; i++)
            {
                linesString[i] = lines[i].ToString();
            }

            return(linesString);
        }
예제 #3
0
        public static void Output(SimpleQueue <Angajat> listaAngajati, string path)
        {
            string[] lines = GetAngajatiInLines(listaAngajati);

            System.IO.File.WriteAllLines(path, lines);
        }