public void Book()
        {
            var defaultCab = new UberCab()
            {
                ID = -1
            };
            var availableCab = cabs.Where(x => x.CabState.GetType() == typeof(CabAvailableState)).DefaultIfEmpty(defaultCab).FirstOrDefault();

            if (availableCab != default(UberCab))
            {
                availableCab.Book();
            }
        }
Exemple #2
0
 public void StartTrip(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} is already in transit");
 }
Exemple #3
0
 public void RideComplete(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} ride completed");
     cab.CabState = new CabAvailableState();
 }
Exemple #4
0
 public void Cancelled(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} can't be cancelled since its in transit");
 }
Exemple #5
0
 public void Book(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} is unavailable");
 }
 public void StartTrip(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} cant start trip since its not booked");
 }
 public void RideComplete(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} ride can't be complete since its not booked");
 }
 public void Cancelled(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} can't be cancelled since its not booked");
 }
 public void Book(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} booked");
     cab.CabState = new CabBookedState();
 }
 public void StartTrip(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} trip started");
     cab.CabState = new CabInTransitState();
 }
 public void RideComplete(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} ride can't be complete since trip has not started");
 }
 public void Cancelled(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} has been cancelled");
     cab.CabState = new CabAvailableState();
 }
 public void Book(UberCab cab)
 {
     Console.WriteLine($"{cab.Name} can't be booked since its already booked");
 }