evgeni_tsn

Untitled

Nov 30th, 2015
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. public override void Execute(string[] commandArgs)
  2.         {
  3.             string locationName = commandArgs[1];
  4.  
  5.             IEnumerable<IStarship> intactShips =
  6.                 this.GameEngine.Starships
  7.                     .Where(s => s.Location.Name == locationName)
  8.                     .Where(s => s.Health > 0)
  9.                     .OrderBy(s => s.Health)
  10.                     .ThenBy(s => s.Shields)
  11.                     .ToList();
  12.  
  13.             StringBuilder output = new StringBuilder();
  14.             output.AppendLine("Intact ships:");
  15.             output.AppendLine(intactShips.Any() ? string.Join("\n", intactShips) : "N/A");
  16.  
  17.             IEnumerable<IStarship> destroyedShips =
  18.                 this.GameEngine.Starships
  19.                 .Where(s => s.Health <= 0)
  20.                 .OrderBy(s => s.Name)
  21.                 .ToList();
  22.  
  23.             output.AppendLine("Destroyed ships:");
  24.             output.Append(destroyedShips.Any() ? string.Join("\n", destroyedShips) : "N/A");
  25.  
  26.             Console.WriteLine(output.ToString());
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment