Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SpaceStation.Models.Astronauts.Contracts;
  6. using SpaceStation.Models.Planets;
  7.  
  8. namespace SpaceStation.Models.Mission
  9. {
  10. public class Mission : IMission
  11. {
  12. //public void Explore(IPlanet planet, ICollection<IAstronaut> astronauts)
  13. //{
  14. // var removedItems = new List<string>();
  15. // foreach (var currentAstronaut in astronauts)
  16. // {
  17. // if (!currentAstronaut.CanBreath)
  18. // {
  19. // continue;
  20. // }
  21. // foreach (var currenItem in planet.Items)
  22. // {
  23. // currentAstronaut.Bag.Items.Add(currenItem);
  24. // currentAstronaut.Breath();
  25. // removedItems.Add(currenItem);
  26. // if (!currentAstronaut.CanBreath)
  27. // {
  28. // break;
  29. // }
  30. // }
  31. // foreach (var item in removedItems)
  32. // {
  33. // planet.Items.Remove(item);
  34. // }
  35. // }
  36. //}
  37.  
  38. public void Explore(IPlanet planet, ICollection<IAstronaut> astronauts)
  39. {
  40. foreach (var astronaut in astronauts)
  41. {
  42. while (astronaut.CanBreath && planet.Items.Count > 0)
  43. {
  44. string item = planet.Items.ElementAt(0);
  45. planet.Items.Remove(planet.Items.ElementAt(0));
  46. astronaut.Bag.Items.Add(item);
  47. astronaut.Breath();
  48. }
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement