Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace buying_hruchevo
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {          
  13.             int nachos = 0;
  14.             int borjomi = 0;
  15.             int pepsi = 0;
  16.             int popcorn = 0;
  17.             int money = 300;
  18.             Hruchevo hruchevo = new Hruchevo(nachos, borjomi, pepsi, popcorn);
  19.             Console.WriteLine("ну чё, надо купить hruchevo и сделать пердёжный чай!");
  20.             Console.WriteLine("у тебя 300 рублей. выбирай хрючево с умом, записывая цифру хрючева:");
  21.             Console.WriteLine("\n1. начос                       60 рублей\n2. боржоми 0.33                35 рублей\n3. bepis 2 литра               60 рублей\n4. микроволновочный попкорн    25 рублей");
  22.             int choice = Convert.ToInt32(Console.ReadLine());
  23.             if (choice == 1)
  24.             {
  25.                 Console.WriteLine("начос наше всё! сколько пачек берём?");
  26.                 int nachos_quantity = Convert.ToInt32(Console.ReadLine());
  27.                
  28.                 if (nachos_quantity == 1)
  29.                 {
  30.                     hruchevo.BuyNachos();
  31.                     Console.WriteLine("эта пачка будет сожрана незамедлительно. Осталось " + money + " рублей");
  32.                 }
  33.                 if (nachos_quantity == 2)
  34.                 {
  35.                     hruchevo.BuyNachos();
  36.                     hruchevo.BuyNachos();
  37.                     Console.WriteLine("2 начоса. Осталось " + money + " рублей");
  38.                 }
  39.                 if (nachos_quantity == 3)
  40.                 {
  41.                     hruchevo.BuyNachos();
  42.                     hruchevo.BuyNachos();
  43.                     hruchevo.BuyNachos();
  44.                     Console.WriteLine("3 начоса. Осталось " + money + " рублей");
  45.                 }
  46.                 if (nachos_quantity == 4)
  47.                 {
  48.                     hruchevo.BuyNachos();
  49.                     hruchevo.BuyNachos();
  50.                     hruchevo.BuyNachos();
  51.                     hruchevo.BuyNachos();
  52.                     Console.WriteLine("4 начоса. Осталось " + money + " рублей");
  53.                 }
  54.                 if (nachos_quantity == 5)
  55.                 {
  56.                     hruchevo.BuyNachos();
  57.                     hruchevo.BuyNachos();
  58.                     hruchevo.BuyNachos();
  59.                     hruchevo.BuyNachos();
  60.                     hruchevo.BuyNachos();
  61.                     Console.WriteLine("5 начосов. ты ебанутый? денег то не осталось. жри свой начос");
  62.                 }
  63.  
  64.                 if (nachos_quantity == 0)
  65.                     Console.WriteLine("ну и нахуя ты выбрал начос, если не хочешь его брать?");
  66.  
  67.                 if (nachos_quantity < 0)
  68.                 {
  69.                     Console.WriteLine("ты всё испортил!!! то что произошло - невозможно!!! удаляйся нахуй!!!");
  70.                     Console.ReadKey();
  71.                     Environment.Exit(0);
  72.                 }
  73.  
  74.  
  75.  
  76. КЛАСС Hruchevo:
  77.  
  78.  
  79. using System;
  80. using System.Collections.Generic;
  81. using System.Linq;
  82. using System.Text;
  83. using System.Threading.Tasks;
  84.  
  85. namespace buying_hruchevo
  86. {
  87.     public class Hruchevo
  88.     {
  89.         private int nachos;
  90.         private int borjomi;
  91.         private int pepsi;
  92.         private int popcorn;
  93.         public int money = 300;
  94.        
  95.         public Hruchevo(int nachos, int borjomi, int pepsi, int popcorn)
  96.         {
  97.             this.nachos = nachos;
  98.             this.borjomi = borjomi;
  99.             this.pepsi = pepsi;
  100.             this.popcorn = popcorn;
  101.         }
  102.            
  103.             int nachos_price = 60;
  104.             int borjomi_price = 35;
  105.             int pepsi_price = 60;
  106.             int popcorn_price = 25;
  107.  
  108.              public int BuyNachos() //тот самый метод(функция). чекает, достаточно ли денег, и если да, то вычитает из денег цену начоса и впихивает это значение в деньги,
  109.             {                      
  110.             if (money >= nachos_price)
  111.             {
  112.                 money = money - nachos_price;
  113.                 nachos++;                
  114.             }
  115.             return nachos;
  116.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement