Advertisement
Alexander_Maximov

Untitled

Mar 31st, 2023
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Avtoservice
  4. {
  5.     public class Client
  6.     {
  7.         public int DesiredGear { get; }
  8.         private int _money;
  9.         private int _moneyToPay;
  10.        
  11.         public Client(int money, Random random)
  12.         {
  13.             _money = money;
  14.             DesiredGear = random.Next(1, 11);
  15.         }
  16.  
  17.         public bool CheckSolvency(Gear gear)
  18.         {
  19.             _moneyToPay = gear.PriceForItem + gear.PriceForAssembling;
  20.             if (_money >= _moneyToPay)
  21.             {
  22.                 return true;
  23.             }
  24.             else
  25.             {
  26.                 _moneyToPay = 0;
  27.                 return false;
  28.             }
  29.         }
  30.  
  31.         public int Pay()
  32.         {
  33.             _money -= _moneyToPay;
  34.             return _moneyToPay;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement