Exemple #1
0
        public GradeAvg[] GetAll()
        {
            var result = new GradeAvg[Count];

            for (int i = 0; i < Count; i++)
            {
                result[i] = _gt[i];
            }
            return(result);
        }
Exemple #2
0
 public bool Delete(int position)
 {
     GradeAvg[] newAvg = new GradeAvg[_gt.Length - 1];
     for (int i = 0; i < position; i++)
     {
         newAvg[i] = _gt[i];
     } //nahrání prvků až do position
     for (int i = position + 1; i < _gt.Length; i++)
     {
         newAvg[i] = _gt[i];
     } //přeskočí prvek na position a nahraje zbylé
     _gt = newAvg;
     return(true);
 }
Exemple #3
0
 public bool Delete(GradeAvg g)
 {
     GradeAvg[] newAvg = new GradeAvg[_gt.Length - 1];
     for (int i = 0; i < IndexOf(g); i++)
     {
         newAvg[i] = _gt[i];
     }
     for (int i = IndexOf(g) + 1; i < _gt.Length; i++)
     {
         newAvg[i] = _gt[i];
     }
     _gt = newAvg;
     return(true);
 }
Exemple #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;
        }
Exemple #5
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>
        public int Add(GradeAvg g)
        {
            //přidáváme nový GradeAvg a případně předtím zvětšíme pole: ResizeArray(ref _gt, maxcnt)
            int idx = IndexOf(g);

            if (idx == -1)
            {
                idx = Count;
                if (idx == Length)
                {
                    ResizeArray(ref _gt, maxcnt);
                }
                _gt[idx] = g;
            }
            else
            {
                _gt[idx].Count += g.Count;
                _gt[idx].Score += g.Score;
            }

            return(idx);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Display displayGrading = new Display(20, 5, 5, 5);

            displayGrading.AddItem(new Item("-- Vysvědčení --", ""));
            displayGrading.AddItem(new Item("", ""));
            Display displayInput = new Display(20, 5, 5, 5);

            displayInput.AddItem(new Item("---- zadávání předmětu ----", ""));
            displayInput.AddItem(new Item("Předmět", ""));
            Display displayInput2 = new Display(20, 5, 5, 5);

            displayInput2.AddItem(new Item("---- zadávání známky ----", ""));
            displayInput2.AddItem(new Item("Známka", ""));
            Display displayConfirm = new Display(20, 5, 5, 5);

            displayConfirm.AddItem(new Item("Chceš vložit dalšího? [A]", ""));



            Grade[] grades = new Grade[9];
            grades[0] = new Grade()
            {
                Subject = "MAT", Score = 1
            };
            grades[1] = new Grade()
            {
                Subject = "CJL", Score = 4
            };
            grades[2] = new Grade()
            {
                Subject = "PRG", Score = 1
            };
            grades[3] = new Grade()
            {
                Subject = "MAT", Score = 2
            };
            grades[4] = new Grade()
            {
                Subject = "CJL", Score = 5
            };
            grades[5] = new Grade()
            {
                Subject = "CJL", Score = 3
            };
            grades[6] = new Grade()
            {
                Subject = "PRG", Score = 1
            };
            grades[7] = new Grade()
            {
                Subject = "MAT", Score = 2
            };
            grades[8] = new Grade()
            {
                Subject = "MAT", Score = 2
            };

            ConsoleKeyInfo result;

            do
            {
                int    grade;
                string temp;
                displayInput.Repaint();
                temp = Console.ReadLine();
                displayInput2.Repaint();
                int.TryParse(Console.ReadLine(), out grade);
                if (temp.Length == 3 && grade < 6 && grade > 0)
                {
                    table.AddGrade(new Grade()
                    {
                        Score = grade, Subject = temp
                    });
                }

                displayConfirm.Repaint();
                result = Console.ReadKey();
                Console.Clear();
            } while (result.Key == ConsoleKey.A || result.Key == ConsoleKey.Enter);

            foreach (var grade in grades)
            {
                GradeAvg ga = table.AddGrade(grade);
            }

            foreach (var item in table.GetAllGrades())
            {
                displayGrading.AddItem(new Item(item.Subject, item.GetAverage()));
            }

            Console.Clear();
            displayGrading.Repaint();


            Console.ReadKey();
        }
Exemple #7
0
 public int IndexOf(GradeAvg g)
 {
     return(IndexOf(g.Subject));
 }
Exemple #8
0
        static void Main(string[] args)

        {
            CertificateTable table = new CertificateTable();

            Display displayGrading = new Display(new Proportion()
            {
                Width = 40, TopLeft = new System.Drawing.Point(20, 3)
            });

            displayGrading.AddItem(new LabelItem("-- Vysvědčení --"));
            displayGrading.AddItem(new LabelItem(""));
            Display displayInput = new Display(new Proportion()
            {
                Width = 30, TopLeft = new System.Drawing.Point(3, 3)
            });

            displayInput.AddItem(new LabelItem("---- zadávání předmětu ----"));
            displayInput.AddItem(new LabelItem("Předmět", ""));
            Display displayInput2 = new Display(new Proportion()
            {
                Width = 30, TopLeft = new System.Drawing.Point(38, 3)
            });

            displayInput2.AddItem(new LabelItem("---- zadávání známky ----"));
            displayInput2.AddItem(new LabelItem("Známka", ""));
            Display displayConfirm = new Display(new Proportion()
            {
                Width = 30, TopLeft = new System.Drawing.Point(25, 12)
            });

            displayConfirm.AddItem(new LabelItem("Chceš vložit dalšího? [A]", ""));

            Grade[] grades = new Grade[9];
            grades[0] = new Grade()
            {
                Subject = "MAT", Score = 1
            };
            grades[1] = new Grade()
            {
                Subject = "CJL", Score = 4
            };
            grades[2] = new Grade()
            {
                Subject = "PRG", Score = 1
            };
            grades[3] = new Grade()
            {
                Subject = "MAT", Score = 2
            };
            grades[4] = new Grade()
            {
                Subject = "CJL", Score = 5
            };
            grades[5] = new Grade()
            {
                Subject = "CJL", Score = 3
            };
            grades[6] = new Grade()
            {
                Subject = "PRG", Score = 1
            };
            grades[7] = new Grade()
            {
                Subject = "MAT", Score = 2
            };
            grades[8] = new Grade()
            {
                Subject = "MAT", Score = 2
            };

            GradeAvg mat = new GradeAvg("MAT");
            GradeAvg cjl = new GradeAvg("CJL");
            GradeAvg prg = new GradeAvg("PRG");

            mat.GetAverage();
            cjl.GetAverage();
            prg.GetAverage();
            ConsoleKeyInfo result;

            do
            {
                int    grade;
                string temp;
                displayInput.Refresh();
                temp = Console.ReadLine();
                displayInput2.Refresh();
                int.TryParse(Console.ReadLine(), out grade);
                if (temp.Length == 5 && grade < 5 && grade > 0)
                {
                    table.AddGrade(new Grade()
                    {
                        Score = grade, Subject = temp
                    });
                }

                displayConfirm.Refresh();
                result = Console.ReadKey();
                Console.Clear();
            } while (result.Key == ConsoleKey.A || result.Key == ConsoleKey.Enter);

            foreach (var grade in grades)
            {
                GradeAvg ga = table.AddGrade(grade);
            }

            foreach (var item in table.GetAllGrades())
            {
                displayGrading.AddItem(new LabelItem(item.Subject, item.GetAverage()));
            }

            Console.Clear();
            displayGrading.Refresh();


            Console.ReadKey();
        }
Exemple #9
0
 public bool Delete(GradeAvg g)
 {
     throw new NotImplementedException();
 }
Exemple #10
0
        static void Main(string[] args)
        {
            CertificateTable table = new CertificateTable();

            Display displayConfirm = new Display(35, 15, 10, 10);
            Display displayInput   = new Display(35, 15, 10, 10);
            Display displayInput2  = new Display(35, 15, 10, 10);
            Display displayGrading = new Display(35, 15, 10, 10);

            Grade[] grades = new Grade[9];
            grades[0] = new Grade()
            {
                Subject = "MAT", Score = 1
            };
            grades[1] = new Grade()
            {
                Subject = "CJL", Score = 4
            };
            grades[2] = new Grade()
            {
                Subject = "PRG", Score = 1
            };
            grades[3] = new Grade()
            {
                Subject = "MAT", Score = 2
            };
            grades[4] = new Grade()
            {
                Subject = "CJL", Score = 5
            };
            grades[5] = new Grade()
            {
                Subject = "CJL", Score = 3
            };
            grades[6] = new Grade()
            {
                Subject = "PRG", Score = 1
            };
            grades[7] = new Grade()
            {
                Subject = "MAT", Score = 2
            };
            grades[8] = new Grade()
            {
                Subject = "MAT", Score = 2
            };

            displayInput.AddItem(new Item("---- zadávání předmětu ----", ""));
            displayInput.AddItem(new Item("Zadejte předmět: ", ""));
            displayInput2.AddItem(new Item("---- zadávání známky ----", ""));
            displayInput2.AddItem(new Item("Zadejte známku: ", ""));
            displayConfirm.AddItem(new Item("Chceš vložit dalšího? [A/N]", ""));
            string pokracovat = "A";

            while (true)
            {
                if (pokracovat != "A")
                {
                    break;
                }
                else
                {
                    Grade[] grades1 = new Grade[grades.Length + 1];
                    for (int i = 0; i < grades.Length; i++)
                    {
                        grades1[i] = grades[i];
                    }
                    grades = grades1;
                    displayInput.Repaint();
                    string subject = Console.ReadLine();
                    while ((subject != "PRG") && (subject != "MAT") && (subject != "CJL"))
                    {
                        Console.WriteLine("Nevalidní předmět. Zadejte znovu: ");
                        subject = Console.ReadLine();
                        if (subject == "PRG" || subject == "MAT" || subject == "CJL")
                        {
                            break;
                        }
                    }
                    displayInput2.Repaint();
                    string znamčička = Console.ReadLine();
                    while (true)
                    {
                        while (!(int.TryParse(znamčička, out int result)))
                        {
                            Console.WriteLine("Zadej číslo: ");
                            znamčička = Console.ReadLine();
                        }
                        int znamka = int.Parse(znamčička);
                        if (znamka > 5 || znamka < 1)
                        {
                            Console.WriteLine("Zadej číslo v rozmezí 1-5: ");
                            znamčička = Console.ReadLine();
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                    grades[grades.Length - 1] = new Grade()
                    {
                        Subject = subject, Score = Convert.ToDouble(znamčička)
                    };

                    displayConfirm.Repaint();
                    pokracovat = Console.ReadLine();
                }
            }

            displayGrading.AddItem(new Item("-- Vysvědčení --", ""));
            displayGrading.AddItem(new Item("", ""));
            foreach (var grade in grades)
            {
                GradeAvg ga = table.AddGrade(grade);
            }

            foreach (var item in table.GetAllGrades())
            {
                displayGrading.AddItem(new Item(item.Subject, item.GetAverage()));
            }
            displayGrading.Repaint();
            Console.ReadKey();
        }