Advertisement
KDT85

TaxiManager

Mar 29th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Dynamic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace TaxiManagement
  10. {
  11.     public class TaxiManager
  12.     {
  13.         private SortedDictionary<int,Taxi> taxi = new SortedDictionary<int, Taxi>();
  14.  
  15.         public Taxi CreateTaxi(int taxiNum)
  16.         {
  17.             Console.WriteLine("CreateTaxi Called");
  18.             Console.WriteLine(taxiNum);
  19.  
  20.             if (taxi.ContainsKey(taxiNum))
  21.             {
  22.  
  23.                 return taxi[taxiNum];
  24.             }
  25.             else
  26.             {
  27.                 taxi.Add(taxiNum, new Taxi(taxiNum));
  28.                 return new Taxi(taxiNum);
  29.             }
  30.  
  31.         }
  32.         public Taxi FindTaxi(int taxiNum)
  33.         {
  34.             Console.WriteLine("FindTaxi Called");
  35.             if (taxi.ContainsKey(taxiNum))
  36.             {
  37.                
  38.                 return taxi[taxiNum];
  39.             }
  40.             else
  41.             {
  42.                 CreateTaxi(taxiNum);
  43.                
  44.                 return null;
  45.             }
  46.  
  47.         }
  48.  
  49.         public SortedDictionary<int, Taxi> GetAllTaxis()
  50.         {
  51.             Console.WriteLine("GetAllTaxi Called");
  52.            
  53.             return taxi;
  54.         }
  55.  
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement