Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _02_BreadFactory
- {
- class Program
- {
- static void Main(string[] args)
- {
- // (Demo) Technology Fundamentals Mid Exam - 02 March 2019
- string[] inputCases = Console.ReadLine().Split("|");
- int energy = 100;
- int coins = 100;
- for (int i = 0; i < inputCases.Length; i++)
- {
- string[] currentCase = inputCases[i].Split("-");
- string command = currentCase[0];
- int value = int.Parse(currentCase[1]);
- switch (command)
- {
- case "rest":
- energy += value;
- if (energy >100 )
- {
- energy = 100;
- value = 0;
- }
- Console.WriteLine($"You gained {value} energy.");
- Console.WriteLine($"Current energy: {energy}.");
- break;
- case "order":
- energy -= 30;
- if (energy < 0)
- {
- energy += 80; // energy += 50;
- Console.WriteLine("You had to rest!");
- }
- else
- {
- coins += value;
- //energy -= 30;
- Console.WriteLine($"You earned {value} coins.");
- }
- break;
- default:
- if (coins > value) // Π’ΡΠΊΠ°
- {
- Console.WriteLine($"You bought {command}.");
- coins -= value;
- }
- else
- {
- Console.WriteLine($"Closed! Cannot afford {command}.");
- return;
- }
- break;
- }
- }
- Console.WriteLine("Day completed!");
- Console.WriteLine($"Coins: {coins}");
- Console.WriteLine($"Energy: {energy}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement