Skip to content

Instantly share code, notes, and snippets.

@Hellhackee
Created November 19, 2020 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hellhackee/8754702f9f490c435224d77e2b05a6ff to your computer and use it in GitHub Desktop.
Save Hellhackee/8754702f9f490c435224d77e2b05a6ff to your computer and use it in GitHub Desktop.
CS Light Lesson 4.1(crystall's shop)
int goldCount;
int price = 12;
int crystallCount;
bool enoughGold;
Console.WriteLine("Доброго времени суток, путник, ты попал в лавку драгоценностей.");
Console.WriteLine($"Я готов предложить на продажу кристаллы по {price} золотых монет.");
Console.Write("Сколько золота у вас сейчас: ");
goldCount = Convert.ToInt32(Console.ReadLine());
Console.Write("Сколько кристаллов ты хочешь купить: ");
crystallCount = Convert.ToInt32(Console.ReadLine());
enoughGold = goldCount >= price * crystallCount;
crystallCount *= Convert.ToInt32(enoughGold);
goldCount -= crystallCount * price;
Console.WriteLine($"Сейчас у вас в кошельке {goldCount} золотых монет и {crystallCount} кристалла в рюкзаке.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment