public static bool CanRoad(PicoPlaca obj) { int dayOfPlate = DayOfLastDigitPlate(obj.NumberPlate); int dayOfDate = VerifyDayOnDate(obj.FormattedDate); bool TimeRestriction = VerifyTime(obj.FormattedTime); //Calculate if the day of plate and the day of date are the same bool dayAndPlateEqual; if (dayOfPlate == dayOfDate) { dayAndPlateEqual = true; } else { dayAndPlateEqual = false; } //validate if dayAndPlateEqual and TimeRestriction are true then car cant road, else car cant road if (TimeRestriction && dayAndPlateEqual) { return(false); } else { return(true); } }
//calculate if the car can or cannot go to streets private static void CalculateCanRoad(int platenumber, string date, string time) { PicoPlaca objPicoPlata = new PicoPlaca(); objPicoPlata.FormattedDate = date; objPicoPlata.FormattedTime = time; objPicoPlata.NumberPlate = platenumber; //validate if the car can or cannot road if (Methods.CanRoad(objPicoPlata)) { Console.WriteLine("You can go to the streets! :-)"); } else { Console.WriteLine("You cannot go to the streets! :-("); } }