Ejemplo n.º 1
0
        public static void GetChoice(ref GropeAthlete ga)
        {
            int choise = 0;

            Console.SetCursorPosition(OFFSET, choise + 1);

            ConsoleKeyInfo cci = new ConsoleKeyInfo();

            do
            {
                try
                {
                    cci = Console.ReadKey();
                    bool startFunc = Move(cci.Key, ref choise);
                    if (startFunc)
                    {
                        Console.Clear();
                        StartUserChoise(ref ga);
                        Console.Clear();
                        ShowMenu();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    System.Threading.Thread.Sleep(3000);
                    Console.Clear();
                    ShowMenu();
                }
            } while (choise != MAX_CHOISE || cci.Key != ConsoleKey.Enter);
        }
Ejemplo n.º 2
0
        private static int GetIndexDeleter(GropeAthlete ga)
        {
            int  index = 0;
            bool exit  = false;

            if (ga.Count == 0)
            {
                return(-1);
            }
            do
            {
                try
                {
                    Console.WriteLine("Set index to delete = > ");
                    index = int.Parse(Console.ReadKey().KeyChar.ToString());

                    if (index < 0 || index > ga.Count)
                    {
                        throw new Exception("Index Out Of Range");
                    }
                }
                catch (Exception ex)
                {
                    exit = true;
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Try agan");
                }
            } while (exit);

            return(index);
        }
Ejemplo n.º 3
0
        private static void ParticipantShow(ref GropeAthlete ga)
        {
            if (ga.Count == 0)
            {
                throw new EmptyException("Grope is empty");
            }

            Console.WriteLine("Show is end");
            Console.WriteLine("Judge is going to set marks");
            for (int i = 0; i < ga.Count; i++)
            {
                ga.SetMarks(i, Judge.GetMarks());
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            try
            {
                GropeAthlete ga = new GropeAthlete();

                UI.ShowMenu();
                UI.GetChoice(ref ga);
            }

            catch (NullReferenceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch
            {
                Console.WriteLine("Somthing Wrong");
            }
        }
Ejemplo n.º 5
0
        private static void StartUserChoise(ref GropeAthlete ga)
        {
            try
            {
                switch (_mfs)
                {
                case FuncStart.Add:
                    ga.Add(GetNewParticipant());
                    break;

                case FuncStart.Delete:
                    ga.Delete(GetIndexDeleter(ga));
                    break;

                case FuncStart.RemoveMinMax:
                    Mark.SetMarksDelta(ga);
                    break;

                case FuncStart.Show:
                    Viewer.Print(ga);
                    break;

                case FuncStart.Sort:
                    ga.Sort();
                    break;

                case FuncStart.StartParticipant:
                    ParticipantShow(ref ga);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public IteratorParticipant(GropeAthlete par)
 {
     _mPar = par;
     _mPos = -1;
 }