Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _2.Baking_Rush
- {
- class Program
- {
- public static void Main()
- {
- int energy = 100;
- int coins = 100;
- string[] arrayFromEvents = Console.ReadLine().Split('|').ToArray();
- bool finishedDay = true;
- for (int i = 0; i < arrayFromEvents.Length; i++)
- {
- string[] oneEvent = arrayFromEvents[i].Split('-').ToArray();
- string action = oneEvent[0];
- int counter = int.Parse(oneEvent[1]);
- if(action == "rest")
- {
- if (energy + counter >= 100)
- {
- counter = counter - ((energy + counter) - 100);
- }
- energy += counter;
- Console.WriteLine($"You gained {counter} energy.");
- Console.WriteLine($"Current energy: {energy}.");
- }
- else if(action == "order")
- {
- if(energy >= 30)
- {
- energy -= 30;
- coins += counter;
- Console.WriteLine($"You earned {counter} coins.");
- }
- else
- {
- energy += 50;
- Console.WriteLine("You had to rest!");
- }
- }
- else
- {
- if (coins > counter)
- {
- coins -= counter;
- Console.WriteLine($"You bought {action}.");
- }
- else
- {
- Console.WriteLine($"Closed! Cannot afford oven.");
- finishedDay = false;
- return;
- }
- }
- }
- if(finishedDay)
- {
- Console.WriteLine("Day completed!");
- Console.WriteLine($"Coins: {coins}");
- Console.WriteLine($"Energy: {energy}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement