Exemplo n.º 1
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            Angajat angajat1 = obj as Angajat;

            if (this.firstName.Equals(angajat1.firstName))
            {
                int ret = angajat1.lastName.CompareTo(this.lastName);
                if (ret == 0)
                {
                    return(0);
                }
                else
                {
                    return(ret);
                }
            }
            else
            {
                return(angajat1.firstName.CompareTo(this.firstName));
            }
        }
Exemplo n.º 2
0
        private static List <Angajat> GetLinesToList(string[] lines)
        {
            List <Angajat> listaAngajati = new List <Angajat>();

            for (int i = 0; i < lines.Length; i++)
            {
                Angajat angajat = new Angajat();
                char[]  seps    = { ' ' };

                StringBuilder nume    = new StringBuilder();
                StringBuilder prenume = new StringBuilder();

                string[] tokens = lines[i].Split(seps, StringSplitOptions.RemoveEmptyEntries);

                nume.Append(tokens[0]);
                prenume.Append(tokens[1]);


                string[] tokensVechime = tokens[2].Split(new char[] { '/' });
                short    vechimeLuna   = short.Parse(tokensVechime[0]);
                int      vechimeAn     = int.Parse(tokensVechime[1]);

                angajat.Nume    = nume.ToString();
                angajat.Prenume = prenume.ToString();
                angajat.setVechime(vechimeAn, vechimeLuna);

                listaAngajati.Add(angajat);
            }

            return(listaAngajati);
        }
Exemplo n.º 3
0
        public void Remove(string remove)
        {
            int idx = -1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i].nume == remove)
                {
                    idx = i;
                    break;
                }
            }
            if (idx != -1)
            {
                Angajat[] t = new Angajat[a.Length - 1];
                for (int i = 0; i < idx; i++)
                {
                    t[i] = a[i];
                }
                for (int i = idx + 1; i < a.Length; i++)
                {
                    t[i - 1] = a[i];
                }
                a = t;
            }
        }
Exemplo n.º 4
0
        public int Compare(object x, object y)
        {
            Angajat x1 = (Angajat)x;
            Angajat y1 = (Angajat)y;

            return(x1.Nume[0].CompareTo(y1.Nume[0]));
        }
Exemplo n.º 5
0
 public void Add(Angajat add)
 {
     Angajat[] t = new Angajat[a.Length + 1];
     for (int i = 0; i < a.Length; i++)
     {
         t[i] = a[i];
     }
     t[a.Length] = add;
     a           = t;
 }
Exemplo n.º 6
0
 public static int CompareByNames(Angajat angajat1, Angajat angajat2)
 {
     if (angajat2.firstName.Equals(angajat1.firstName))
     {
         int ret = angajat1.lastName.CompareTo(angajat2.lastName);
         if (ret == 0)
         {
             return(0);
         }
         else
         {
             return(ret);
         }
     }
     else
     {
         return(angajat1.firstName.CompareTo(angajat2.firstName));
     }
 }
Exemplo n.º 7
0
        public List <Angajat> Read()
        {
            Console.WriteLine("Reading from [" + this.fileName + "]");

            List <Angajat> angajat = new List <Angajat>();

            string[]    lines    = File.ReadAllLines(this.fileName);
            CultureInfo provider = CultureInfo.InvariantCulture;

            foreach (string line in lines)
            {
                string[] tokens = line.Split(' ');

                string   firstName      = tokens[0];
                string   lastName       = tokens[1];
                DateTime employmentDate = DateTime.ParseExact(tokens[2], "dd/MM/yyyy", provider);

                Angajat a = new Angajat(firstName, lastName, employmentDate);
                angajat.Add(a);
            }

            return(angajat);
        }
Exemplo n.º 8
0
 public void Remove(Angajat angajat)
 {
     this.listaAngajati.Remove(angajat);
 }
Exemplo n.º 9
0
 public void Add(Angajat angajat)
 {
     this.listaAngajati.Add(angajat);
 }
Exemplo n.º 10
0
 public static int CompareByEmploymentDate(Angajat angajat1, Angajat angajat2)
 {
     return(angajat1.employmentDate.CompareTo(angajat2.employmentDate));
 }