Пример #1
0
        public MenuMain(DisplayController dc, GarageController gc)
        {
            Titel   = "Main Menu:";
            Answers = new string[] {
                "Exit",
                "Check In Vehicle",
                "Search For Vehicle",
            };
            dc.Layer++;
            Length = Answers.Length;
            int nav = 0;

            do
            {
                nav = GetAnswer(dc);
                switch (nav)
                {
                case 1:
                    new MenuCheckIn(dc, gc);
                    break;

                case 2:
                    new MenuSearch(dc, gc);
                    break;

                case 0:
                default:
                    break;
                }
                dc.RemoveLine();
                dc.UpdateDisplay();
            } while (nav != 0);
            dc.Layer--;
            dc.UpdateDisplay();
        }
Пример #2
0
 public void resetDisplay(DisplayController dc)
 {
     foreach (string a in Answers)
     {
         dc.RemoveLine();
     }
 }
Пример #3
0
        public int GetAnswer(DisplayController dc)
        {
            initiateDisplay(dc);
            int nav = dc.GetDirectionalInput(Length);

            resetDisplay(dc);
            return(nav);
        }
Пример #4
0
 public void initiateDisplay(DisplayController dc)
 {
     dc.WriteLine(Titel);
     foreach (string a in Answers)
     {
         dc.WriteLine(a);
     }
 }
Пример #5
0
        public MenuCheckIn(DisplayController dc, GarageController gc)
        {
            Titel   = "Check In Vehicle:";
            Answers = new string[] {
                "Back",
                "Check in a random vehicle",
                "Check in a random Car",
                "Check in a random Motorcycle",
                "Check in a random Truck",
                "Check in a random Bus",
            };
            dc.Layer++;
            Length = Answers.Length;
            int nav = 0;

            do
            {
                nav = GetAnswer(dc);
                switch (nav)
                {
                case 1:
                    dc.InfoText = gc.ParkNewVehicle();
                    break;

                case 2:
                    dc.InfoText = gc.ParkVehicle(v_Vehicle.Car);
                    break;

                case 3:
                    dc.InfoText = gc.ParkVehicle(v_Vehicle.MC);
                    break;

                case 4:
                    dc.InfoText = gc.ParkVehicle(v_Vehicle.Truck);
                    break;

                case 5:
                    dc.InfoText = gc.ParkVehicle(v_Vehicle.Bus);
                    break;

                case 0:
                    break;

                default:
                    break;
                }
                dc.RemoveLine();
                dc.UpdateDisplay();
            } while (nav != 0);
            dc.Layer--;
            dc.UpdateDisplay();
        }
Пример #6
0
        static void MainMenu()
        {
            GarageController  gc = new GarageController();
            DisplayController dc = new DisplayController(gc);

            // For testing
            ////for (int i = 0; i < 10; i++)
            ////{
            ////    gc.ParkNewVehicle();
            ////}
            //gc.LoadGarageFromFile();
            //gc.SaveGarageToFile();
            //gc.LoadGarageFromFile();

            new MenuMain(dc, gc);
        }
Пример #7
0
        public MenuSearchRegNr(DisplayController dc, GarageController gc)
        {
            Titel = "Search By Regnr";
            dc.Layer++;
            dc.WriteLine(Titel);
            dc.UpdateDisplay();
            Console.WriteLine("\n INPUT REGNR: ");
            string searchString = GetInput(false);

            if (gc.FindVehicle(searchString.ToUpper()) != null)
            {
                new MenuThisVehicle(dc, gc, gc.FindVehicle(searchString.ToUpper()));
            }
            else
            {
                dc.InfoText = "No car with that RegNr is parked in the garage";
            }
            dc.RemoveLine();
            dc.Layer--;
            dc.UpdateDisplay();
        }
Пример #8
0
        public MenuThisVehicle(DisplayController dc, GarageController gc, string vehicle)
        {
            Titel   = vehicle;
            Answers = new string[] {
                "Back",
                "Get Info",
                "Check out",
            };
            dc.Layer++;
            Length = Answers.Length;
            int nav = 0;

            do
            {
                nav = GetAnswer(dc);
                switch (nav)
                {
                case 1:
                    dc.InfoText = gc.ViewParkedVehicle(Titel.Substring(0, 6));
                    break;

                case 2:
                    dc.InfoText = gc.VehicleCheckout(Titel.Substring(0, 6));
                    dc.RemoveLine();
                    dc.Layer--;
                    dc.UpdateDisplay();
                    return;

                case 0:
                default:
                    break;
                }
                dc.RemoveLine();
                dc.UpdateDisplay();
            } while (nav != 0);
            dc.Layer--;
            dc.UpdateDisplay();
        }
Пример #9
0
        public MenuSearchType(DisplayController dc, GarageController gc)
        {
            int nav = 0;

            do
            {
                Titel      = "Search By Type:";
                Answers    = new string[Enum.GetNames(typeof(v_Vehicle)).Length + 1];
                Answers[0] = "Back";
                Enum.GetNames(typeof(v_Vehicle)).CopyTo(Answers, 1);
                dc.Layer++;
                Length = Answers.Length;
                nav    = GetAnswer(dc);
                if (nav != 0)
                {
                    new MenuVehicles(dc, gc, (v_Vehicle)nav - 1);
                }
                dc.RemoveLine();
                dc.UpdateDisplay();
                dc.Layer--;
                dc.UpdateDisplay();
            } while (nav != 0);
        }
Пример #10
0
        public MenuVehicles(DisplayController dc, GarageController gc, v_Vehicle type)
        {
            int nav = 0;

            do
            {
                string[] vehicles = gc.FindVehiclesByType(type).ToArray();
                Titel      = "Choose Vehicle:";
                Answers    = new string[vehicles.Length + 1];
                Answers[0] = "Back";
                vehicles.CopyTo(Answers, 1);
                dc.Layer++;
                Length = Answers.Length;
                nav    = GetAnswer(dc);
                if (nav != 0)
                {
                    new MenuThisVehicle(dc, gc, Answers[nav]);
                }
                dc.RemoveLine();
                dc.UpdateDisplay();
                dc.Layer--;
                dc.UpdateDisplay();
            } while (nav != 0);
        }
Пример #11
0
        public MenuSearch(DisplayController dc, GarageController gc)
        {
            Titel   = "Search For Vehicle:";
            Answers = new string[] {
                "Back",
                "Search By Type",
                "Search For A Specific Vehicle",
                "Search Trough All Vehicles"
            };
            dc.Layer++;
            Length = Answers.Length;
            int nav = 0;

            do
            {
                nav = GetAnswer(dc);
                switch (nav)
                {
                case 1:
                    new MenuSearchType(dc, gc);
                    break;

                case 2:
                    new MenuSearchRegNr(dc, gc);
                    break;

                case 0:
                default:
                    break;
                }
                dc.RemoveLine();
                dc.UpdateDisplay();
            } while (nav != 0);
            dc.Layer--;
            dc.UpdateDisplay();
        }