Example #1
0
        static void Main(string[] args)
        {
            CertificateTable table = new CertificateTable();

            Display displayGrading = new Display(20, 3, 40);

            displayGrading.AddItem(new LabelItem("-- Vysvědčení --"));
            displayGrading.AddItem(new LabelItem(""));
            Display displayInput = new Display(3, 3, 30);

            displayInput.AddItem(new LabelItem("---- zadávání předmětu ----"));
            displayInput.AddItem(new LabelItem("Předmět", ""));
            Display displayInput2 = new Display(38, 3, 30);

            displayInput2.AddItem(new LabelItem("---- zadávání známky ----"));
            displayInput2.AddItem(new LabelItem("Známka", ""));
            Display displayConfirm = new Display(25, 12, 30);

            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
            };

            ConsoleKeyInfo result;

            do
            {
                double grade;
                string temp;
                displayInput.Refresh();
                temp = Console.ReadLine();
                displayInput2.Refresh();
                double.TryParse(Console.ReadLine(), out grade);
                if (temp.Length == 3 && grade < 6 && 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();
        }
        static void Main(string[] args)
        {
            CertificateTable table = new CertificateTable();
            //string temp;
            //string temp_2;
            //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]", ""));
            Display d1 = new Display(20, 10);
            //d1.frame();
            //d1.print();
            //d1.back();
            //temp = Console.ReadLine();
            Display d2 = new Display(50, 10);
            //d2.frame();
            //d2.print();
            //d2.back();
            //temp_2 = Console.ReadLine();
            Display d3 = new Display(35, 20);

            //d3.frame();
            //d3.print();


            //Display d2 = new Display("Zadej známku:" + " ", 1, 50, 10);
            //d2.frame();
            //d2.print();
            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
            };
            d1.AddItem("-------PŘEDMĚT-------");
            d1.AddItem("Zadej předmět: ");

            d2.AddItem("-------ZNÁMKA-------");
            d2.AddItem("Zadej známku: ");

            d3.AddItem("Chceš zadat další známku [A]?");

            ConsoleKeyInfo result;

            do
            {
                int    grade;
                string temp, temp_2;
                d1.frame();
                //d1.back(2);
                temp = Console.ReadLine();


                d2.frame();
                temp_2 = Console.ReadLine();
                int.TryParse(temp_2, out grade);
                if (temp.Length == 3 && grade < 6 && grade > 0)
                {
                    table.AddGrade(new Grade()
                    {
                        Score = grade, Subject = temp
                    });
                }

                d3.frame();
                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();
        }
Example #3
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();
        }