public static void deleteByDisplay()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("DELETE A RECORD" + Environment.NewLine);

            //Call a method to read from the list of all records
            RecordList recordsList = MarinaTools.readList();

            Console.ForegroundColor = ConsoleColor.White;
            //Print all the records
            Console.WriteLine(String.Join(Environment.NewLine + Environment.NewLine, recordsList));

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(Environment.NewLine + "Insert the position number that you want to delete >");
            Console.ForegroundColor = ConsoleColor.White;

            string inputNumber;
            bool   repeat;

            do
            {
                inputNumber = Console.ReadLine();
                repeat      = MarinaTools.checkIntInput(inputNumber);
            } while (repeat == true);

            int delNumber = int.Parse(inputNumber);

            finalDelCheck(delNumber, recordsList);
        }
        public static void DeletingMenu()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("DELETE A RECORD" + Environment.NewLine);

            bool repeat;

            do
            {
                Console.WriteLine("Choose a deleting option" + Environment.NewLine);                 // The user can choose to search for name of the owner an of the boat
                Console.ForegroundColor = ConsoleColor.White;                                        // or select a boat from the display of all records
                Console.WriteLine("1 - Search a record by the owner and the boat names" + Environment.NewLine + "2 - Display all records");

                string choice;
                do
                {
                    choice = Console.ReadLine();
                    repeat = MarinaTools.checkIntInput(choice);
                } while (repeat == true);

                int userChoice = int.Parse(choice);

                switch (userChoice)
                {
                case 1:
                    deleteByNames();
                    break;

                case 2:
                    deleteByDisplay();
                    break;

                default:
                    Console.WriteLine("Insert a valid option.");
                    repeat = true;
                    break;
                }
            } while (repeat == true);
        }
Exemple #3
0
        public static void recordValidation()         // the boat measures are checked and the rental price is offered
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("BOOKING PAGE" + Environment.NewLine);
            Console.ForegroundColor = ConsoleColor.White;

            bool repeat;              //variable used to control the following loops

            string inputLength, inputDraft;

            do
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Insert the boat length in meters > ");
                inputLength = Console.ReadLine();
                //check if the input is valid or restart the loop
                repeat = MarinaTools.checkDoubleInput(inputLength);
            }while (repeat == true);


            double length = double.Parse(inputLength.Trim());

            //check that the boat is not too long
            MarinaTools.checkBoatLength(length);

            do
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Insert the boat draft in meters > ");
                inputDraft = Console.ReadLine();
                repeat     = MarinaTools.checkDoubleInput(inputDraft);
            }while (repeat == true);

            double draft = double.Parse(inputDraft.Trim());

            //check that the boat is not to deep
            MarinaTools.checkBoatDraft(draft);

            // check if there is space available
            double spaceAvailable = MarinaTools.spaceAvailable();

            if (length > spaceAvailable)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("We are sorry but there is no space available for your boat. Press enter to go back to the main menu");
                MarinaTools.goBackMainMenu();
            }

            //calculation of the rent price for the chosen period
            string inputMonths;

            do
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Input the duration of your stay in months >");
                Console.ForegroundColor = ConsoleColor.White;
                inputMonths             = Console.ReadLine();
                repeat = MarinaTools.checkIntInput(inputMonths);
            } while(repeat == true);

            int    months = int.Parse(inputMonths.Trim());
            double price  = months * length * 10;            // formula to calculate the rental price

            Console.WriteLine("The price of the stay is " + price + "$");

            DateTime now     = DateTime.Now;
            string   rentEnd = now.AddMonths(months).ToString();

            //user can decide to accept or deny the offer
            do
            {
                string inputDecision;

                do                 //validate the input
                {
                    Console.WriteLine("Enter Y to confirm the booking or N to reject it >");
                    inputDecision = Console.ReadLine();
                    repeat        = MarinaTools.checkStringInput(inputDecision);
                } while (repeat == true);


                string lowDecision = inputDecision.ToLower(new CultureInfo("en-US", false));
                char   decision    = lowDecision[0];


                switch (decision)
                {
                case 'n':
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("No record has been booked. Press enter to go back to the main menu. Thank you");
                    MarinaTools.goBackMainMenu();
                    break;

                case 'y':
                    RecordNode lenghtAndPriceAndDate = new RecordNode(length, price, rentEnd);
                    newRecord();
                    break;

                default:
                    Console.WriteLine("You did not insert a valid option. Try again");
                    repeat = true;
                    break;
                }
            }while (repeat == true);
        }