Example #1
0
 /// <summary>
 ///   Vloží nové souhrnné hodnocení, nebo doplní (přepíše?) stávající
 /// </summary>
 /// <param name="g">souhrnná známka</param>
 /// <returns>index nově vložené známky</returns>
 private int Add(GradeAvg g)
 {
     if (_gt.Length == Count)
     {
         ResizeArray(ref _gt, _gt.Length + maxcnt);
     }
     _gt[Count] = g;
     return(IndexOf(g.Subject));
 }
Example #2
0
        public GradeAvg[] GetAll()
        {
            var result = new GradeAvg[Count];

            for (int i = 0; i < Count; i++)
            {
                result[i] = _gt[i];
            }
            return(result);
        }
Example #3
0
        public bool Insert(GradeAvg g, int position)
        {
            int a = new GradeAvg(g.Subject);

            for (int i = position; _gt.Lenght > i; i--)
            {
                if (_gt.Lenght == Count)
                {
                    ResizeArray(ref _gt, _gt.Length + maxcnt);
                }
                a = IndexOf(position);
            }
        }
Example #4
0
        private static void ResizeArray(ref GradeAvg[] oldArray, int growUp)
        {
            if (growUp < 0)
            {
                throw new ArgumentOutOfRangeException("growUp", "Parametr musí být kladné číslo.");
            }

            GradeAvg[] newGradeAvgs = new GradeAvg[oldArray.Length + growUp];
            for (int i = 0; i < oldArray.Length; i++)
            {
                newGradeAvgs[i] = oldArray[i];
            }
            oldArray = newGradeAvgs;
        }
Example #5
0
        public bool Insert(GradeAvg g, int position)
        {
            int a;

            for (int i = position; _gt.Length > i; i--)
            {
                if (_gt.Length == Count)
                {
                    ResizeArray(ref _gt, _gt.Length + maxcnt);
                }
                a = IndexOf(g);
                return(true);
            }
            return(false);
        }
Example #6
0
        /// <summary>
        ///   Metoda přidá novou známku do souhrnu známek
        /// </summary>
        /// <param name="g">známka</param>
        public void Add(Grade g)
        {
            // 1)  zjistíme, zda předmět je již v _gt (a získáme index)
            // 2)  pokud ne, vytvoříme nový pomocí Add(GradeAvg) (a získáme index)
            // 3)  přes Get() získáme referenci na souhrnnou známku a aktualizujeme ji pomocí "g"
            int index = IndexOf(g.Subject);

            if (index == -1)
            {
                int      a   = Add(new GradeAvg(g.Subject));
                GradeAvg _gt = Get(a);
                _gt.AddGrade(g);
            }
            else
            {
                GradeAvg _gt = Get(index);
                _gt.AddGrade(g);
            }
        }
Example #7
0
 public bool Delete(GradeAvg g)
 {
     throw new NotImplementedException();
 }
Example #8
0
 public int IndexOf(GradeAvg g)
 {
     return(IndexOf(g.Subject));
 }