Exemplo n.º 1
0
 public void ReceiveTrain(ITrain train)
 {
     if (_underMaintenance)
     {
         throw new ApplicationException($"{_name} is currently under maintenance so cannot receive train!");
     }
     if (_trains.Count >= _capacity)
     {
         throw new ApplicationException($"{_name} cannot receive another train! At capacity.");
     }
     if (train.IsMoving)
     {
         _trains.Add(train);
         train.StopMovement();
     }
     else
     {
         throw new ApplicationException("Station cannot accept stopped train");
     }
 }