コード例 #1
0
 public void PayRental(RentContract rent, Repository repo, bool isCash, [Optional] int amount)
 {
     if (rent.HasBeenPayed)
     {
         throw new AlreadyPayedException("This rental has already been payed");
     }
     rent.PrintInfos();
     if (isCash)
     {
         float price = float.Parse(rent.GetPrice());
         if (amount < price)
         {
             Console.WriteLine("You gave to less money...");
             return;
         }
         Console.WriteLine($"Your return money: {amount - price}");
     }
     rent.PayRent();
     repo.Save();
 }
コード例 #2
0
 public void ChooseVehicle(Vehicle vehicle, Repository repo, DateTime rentStart, DateTime rentEnd)
 {
     if (HasChosenEmployee)
     {
         if (repo.CheckAvailablityForDates(rentStart, rentEnd, vehicle) && vehicle.IsReadyForRent())
         {
             var ct = new RentContract(rentStart, rentEnd, vehicle, this);
             new ContractData().AddData(ct, repo);
             vehicle.ToggleRent();
             repo.Save();
             Console.WriteLine("Here is your Contract: ");
             ct.PrintInfos();
             Console.WriteLine("Here your Keys");
         }
         else
         {
             throw (new DatesOverlapException("This vehicle is already reserved for this period"));
         }
     }
     else
     {
         throw (new InvalidOperationException("You have to get an employee"));
     }
 }