/// <summary>
        /// This method gives the user a text about how the program can be used.
        /// </summary>
        private static void HowTo()
        {
            Console.WriteLine("This is Prague Parking v 2.0, the new and improved version!" +

                              "\n\nThe application works so that any questions can be answered with these variations of yes: y or yes." +
                              "\nIf you at any point wish to return to the main menu, please type “EXIT” and press enter." +
                              "\nNote that any changes made prior will not be saved when exiting a menu this way." +

                              "\n\nSince the system now has a parkinglist file that it reads to and from, " +
                              "\ntherefore, the program can be percieved as running a bit slower than its predecessor." +

                              "\n\nPlease note that the configuration file should only be made changes to when the parkinglist is empty!" +
                              "\nThe different values will produce a system collapse." +

                              "\n\nThe pricelist can be changed and re-read while the program is running, it is written in this fomat: " +

                              "\n\ncar:20:per started hour" +
                              "\nmc:10:per started hour" +
                              "\nfree:10:minutes of parking" +

                              "\n\nIf you wish to change these, change nothing but the numbers. After that, just choose menu" +
                              "\nchoise 1 in the \"settings and help menu\" and then confirm the operation with y or yes." +

                              "\n\n\nPress any key to return to the main menu");

            Console.ReadKey();
            Mainmenu.MainMenu();
        }
        /// <summary>
        /// This method is for the "settings and help" menu choice.
        /// </summary>
        public static void SettingsMenu()
        {
            Console.Clear();
            Console.WriteLine("Settings and help. Please type the number of your menu choice" +
                              "\n \n 1. Re-read the pricelist file" +
                              "\n \n 2. How to use the program" +
                              "\n \n 3. Return to the main menu" +
                              "\n");
            Console.Write("Number: ");
            string menuChoice = Console.ReadLine();

            int.TryParse(menuChoice, out int choice);

            if (choice >= 1 && choice <= 4)
            {
                switch (choice)
                {
                case 1: PriceList(); break;

                case 2: HowTo(); break;

                case 3: Mainmenu.MainMenu(); break;

                default:
                    break;
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Invalid input, try again");
                SettingsMenu();
            }
        }
Example #3
0
        /// <summary>
        /// This menu shows when there is one spot for a mc available.
        /// </summary>
        public static void OneSpace()
        {
            Console.Clear();
            Console.WriteLine("Park Vehicle. Please type the number of your menu choice" +
                              "\n \n 1. Park a motorcycle" +
                              "\n \n 2. Return to the main menu" +
                              "\n");
            Console.Write("Number: ");
            string menuChoice = Console.ReadLine();

            int.TryParse(menuChoice, out int choice);

            if (choice >= 1 && choice <= 2)
            {
                switch (choice)
                {
                case 1: ParkingSpot.ParkVehicle("mc"); break;

                case 2: Mainmenu.MainMenu(); break;;

                default:
                    break;
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Invalid input, try again");
                OneSpace();
            }
        }
Example #4
0
        /// <summary>
        /// This menu shows when there are no available spots.
        /// </summary>
        public static void NoSpaces()
        {
            Console.WriteLine("There are no empty spots left, please wait until a vehicle has been checked out before trying again. " +
                              "\n Press any button to return to the main menu.");

            Console.ReadKey();
            Mainmenu.MainMenu();
        }
Example #5
0
        static void Main()
        {
            // Read the config file
            Initilizing.ReadConfigFile();

            // Read the pricelist file
            Initilizing.ReadPriceFile();

            // Read the parkinglist file
            ParkingHouse.ReadParkingFile();

            // Goes into the main menu
            Mainmenu.MainMenu();
        }
        /// <summary>
        /// This method re-reads the pricelist if the user wants it.
        /// </summary>
        private static void PriceList()
        {
            Console.WriteLine($"The current prices for each new hour are {Initilizing.CarCost} CZK/car" +
                              $"\nand { Initilizing.McCost } CZK/Motorcycles. The number of free minutes before the parking starts to cost is { Initilizing.FreeMinutes }." +
                              $"\nWould you like to re-read the pricelist?");
            string confirm = Console.ReadLine();

            if (confirm == "yes" || confirm == "YES" || confirm == "y")
            {
                Initilizing.ReadPriceFile();

                Console.WriteLine($"Ok! The pricefile has been re-read! The prices for each new hour are {Initilizing.CarCost} CZK/car" +
                                  $"\nand { Initilizing.McCost } CZK/Motorcycles. The free minutes value is { Initilizing.FreeMinutes }" +
                                  "\nPress any key to return to the main menu");
                Console.ReadKey();
                Mainmenu.MainMenu();
            }
            else
            {
                Console.WriteLine("Press any key to return to the main menu");
                Console.ReadKey();
                Mainmenu.MainMenu();
            }
        }
Example #7
0
        /// <summary>
        /// This method is for the menu Check out vehicle.
        /// </summary>
        public static void CheckOut()
        {
            Console.Clear();
            Mainmenu.MenuPrinter();
            Console.Write("Please enter the registration number of the vehicle you would like to check out: ");
            string regNr = Console.ReadLine().ToUpper();

            (Vehicle foundVehicle, ParkingSpot spot) = ParkingHouse.FindVehicle(regNr);

            if (spot is not null)
            {
                int vehicleCost = 0;
                if (foundVehicle.value == Initilizing.CarValue)
                {
                    vehicleCost = Initilizing.CarCost;
                }
                else
                {
                    vehicleCost = Initilizing.McCost;
                }
                spot.RemoveVehicle(foundVehicle);
                ParkingHouse.BackUp();
                foundVehicle.timeOut = DateTime.Now;
                TimeSpan parkedTime = foundVehicle.timeOut - foundVehicle.timeIn;
                if (parkedTime.Hours < 1)
                {
                    if (parkedTime.Minutes <= Initilizing.FreeMinutes)
                    {
                        Console.WriteLine($"\nThe parking for { foundVehicle.RegNr } is less than { Initilizing.FreeMinutes } minutes and is therefore without cost. " +
                                          $"\nThis vehicle has been checked out. \n\nPress any key to return to the main menu");
                        Console.ReadKey();
                        Mainmenu.MainMenu();
                    }
                    else
                    {
                        Console.WriteLine($"\nThe vehicle with the regnr { foundVehicle.RegNr } has been parked for more than { Initilizing.FreeMinutes } minutes but less than an hour. " +
                                          $"\nThe cost for this parking is { vehicleCost } CZK. This vehicle has been checked out. \n\nPress any key to return to the main menu");
                        Console.ReadKey();
                        Mainmenu.MainMenu();
                    }
                }
                else
                {
                    if (parkedTime.Days < 30)
                    {
                        int parkedHours = parkedTime.Hours;
                        parkedHours += 1;
                        int startedDays  = parkedTime.Days;
                        int startedHours = parkedHours + (startedDays * 24);
                        vehicleCost = startedHours * vehicleCost;

                        if (parkedTime.Days >= 1)
                        {
                            Console.WriteLine($"\nThe vehicle with the regnr { foundVehicle.RegNr } has been parked for { parkedTime.Days } day(s) and { parkedHours } started hours. " +
                                              $"\nThe cost for this parking is { vehicleCost } CZK. This vehicle has been checked out. \n\nPress any key to return to the main menu");
                            Console.ReadKey();
                            Mainmenu.MainMenu();
                        }
                        else
                        {
                            Console.WriteLine($"\nThe vehicle with the regnr { foundVehicle.RegNr } has been parked for { startedHours } started hours. " +
                                              $"\nThe cost for this parking is { vehicleCost } CZK. This vehicle has been checked out. \n\nPress any key to return to the main menu");
                            Console.ReadKey();
                            Mainmenu.MainMenu();
                        }
                    }
                    else
                    {
                        Console.WriteLine($"\nThe vehicle with the regnr { foundVehicle.RegNr } has been parked for more than a month. " +
                                          $"\nThe cost for this parking is on me :) This vehicle has been checked out. \n\nPress any key to return to the main menu");
                        Console.ReadKey();
                        Mainmenu.MainMenu();
                    }
                }
            }
            else if (regNr == "EXIT")
            {
                Mainmenu.MainMenu();
            }
            else
            {
                Console.WriteLine("There is no vehicle with that registration number, try again");
                Console.ReadKey();
                CheckOut();
            }
        }
Example #8
0
        /// <summary>
        /// This metod is for the menu choice "Search for and move vehicle"
        /// </summary>
        public static void MoveVehicle()
        {
            Console.Clear();
            Mainmenu.MenuPrinter();
            Console.Write("Please enter the registration number of the vehicle you would like to search for: ");
            string regNr = Console.ReadLine().ToUpper();

            if (regNr is not "EXIT")
            {
                (Vehicle foundVehicle, ParkingSpot oldSpot) = ParkingHouse.FindVehicle(regNr);
                if (foundVehicle is not null || oldSpot is not null)
                {
                    Console.Write($"\nThis vehicle is parked in spot { oldSpot.SpotNumber }, would you like to move it?: ");
                    string answer = Console.ReadLine().ToUpper();

                    if (answer == "Y" || answer == "YES")
                    {
                        Console.Write("Ok! Where would you like to park it instead?: ");
                        string spotAnswer = Console.ReadLine();
                        bool   correct    = int.TryParse(spotAnswer, out int spotSuggest);

                        if (correct)
                        {
                            ParkingSpot newSpot = ParkingHouse.FreeSpotFinder(foundVehicle.value, spotSuggest);
                            if (newSpot is not null)
                            {
                                oldSpot.RemoveVehicle(foundVehicle);
                                newSpot.Vehicles.Add(foundVehicle);
                                newSpot.FreeSpace -= foundVehicle.value;
                                Console.WriteLine($"\nThe { foundVehicle.type } with the registration number { foundVehicle.RegNr } " +
                                                  $"\nthat was parked in { oldSpot.SpotNumber } has been moved to { newSpot.SpotNumber }.");
                                ParkingHouse.BackUp();
                            }
                            else
                            {
                                Console.WriteLine("This spot is not available." +
                                                  "\nNo changes have been made, please start over");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Incorrect input, please start from the beginning");
                            Console.ReadKey();
                            MoveVehicle();
                        }
                    }
                    else if (answer == "EXIT")
                    {
                        Mainmenu.MainMenu();
                    }
                    else
                    {
                        Mainmenu.MainMenu();
                    }
                }
                else
                {
                    Console.WriteLine("\nThere is no vehicle parked witht that number, press any key to try again");
                    Console.ReadKey();
                    MoveVehicle();
                }
            }