Example #1
0
 private void displayJourney()  // set the vehicle data into the text field
 {
     DistanceTravelledTxt.Text = J.getdistanceTravelled().ToString();
     JourneyDayTxt.Text        = J.getjourneyAt().Day.ToString();
     JourneyMonthTxt.Text      = J.getjourneyAt().Month.ToString();
     JourneyYearTxt.Text       = J.getjourneyAt().Year.ToString();
     PaidRadioBtn.IsChecked    = J.isPaid();
 }
Example #2
0
        //Check if the vehicle v can be used (rented) for a journey J

        /*
         * returns Boolean[] for each rental condition: Date taken, service required, car doesn't exist yet (earlier than makeYear), Journey too long.
         */
        public Boolean[] isJourneyRentable(Journey J)
        {
            Boolean[] rentable = new bool[] { true, true, true, true }; //Can rent for all reasons

            if (Journey.JourneyDateExists(allJournies, J) == true)
            {
                rentable[0] = false;
            }                         //Check if journey of same date exists in database!

            if (Service.DistanceSinceServiceKm(Service.FindServices(allServices, v.getVehicleID()), v) >= Service.SERVICE_KILOMETER_LIMIT)
            {
                rentable[1] = false;
            }                        //Needs service

            if (J.getjourneyAt().Year - v.getMakeYear() < 0)
            {
                rentable[2] = false;
            }                         //Car doesn't exist yet!

            if (J.getdistanceTravelled() > Journey.JOURNEY_RENT_KM_MAX_LIMIT || J.getdistanceTravelled() <= Journey.JOURNEY_RENT_KM_MIN_LIMIT)
            {
                rentable[3] = false;
            }                        //Journey too long!

            Console.WriteLine("Rentability: " + rentable[0] + ", " + rentable[1] + ", " + rentable[2] + ", " + rentable[3]);
            return(rentable);
        }
 //Check if date for journey exists already
 public static Boolean JourneyDateExists(List <Journey> allJournies, Journey J)
 {
     foreach (Journey j in allJournies)
     {
         //Check if a date is within 24 hours!
         if (Math.Abs((j.getjourneyAt() - J.getjourneyAt()).TotalHours) < 24 && j.getVehicleID() == J.getVehicleID())
         {
             return(true);
         }
     }
     return(false);
 }