Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- List<string> route = Console.ReadLine()
- .Split("||", StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- int fuel = int.Parse(Console.ReadLine());
- int ammunition = int.Parse(Console.ReadLine());
- for (int i = 0; i < route.Count; i++)
- {
- string[] tokens = route[i].Split(' ');
- switch (tokens[0])
- {
- case "Travel":
- if (int.Parse(tokens[1]) <= fuel)
- {
- fuel -=int.Parse(tokens[1]);
- Console.WriteLine($"The spaceship travalled {tokens[1]} light-years.");
- }
- else
- {
- Console.WriteLine("Mission failed.");
- return;
- }
- break;
- case "Enemy":
- if (ammunition >= int.Parse(tokens[1]))
- {
- ammunition -= int.Parse(tokens[1]);
- Console.WriteLine($"An enemy with {tokens[1]} armour is defeated");
- }
- else
- {
- for (int k = 0; k < int.Parse(tokens[1]); k++)
- {
- fuel -= 2;
- }
- if (fuel <= 0 || ammunition < 0)
- {
- Console.WriteLine("Mission failed.");
- return;
- }
- }
- if (fuel > 0)
- {
- Console.WriteLine($"An enemy with {tokens[1]} armour is outmaneuvered.");
- }
- break;
- case "Repair":
- fuel += int.Parse(tokens[1]);
- ammunition += int.Parse(tokens[1]) * 2;
- Console.WriteLine($"Ammunitions added: {int.Parse(tokens[1]) * 2}.");
- Console.WriteLine($"Furl added: {int.Parse(tokens[1])}.");
- break;
- case "Titan":
- Console.WriteLine("You have reached Titan, all passengers are safe.");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement