Advertisement
Rodunskiy

Untitled

May 13th, 2025
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. namespace CSLight
  2. {
  3.     public class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             Player player = new Player("Родион", 25, 80);
  8.  
  9.             player.OutputInformation();
  10.         }
  11.     }
  12.  
  13.     class Player
  14.     {
  15.         private string _name;
  16.         private int _age;
  17.         private float _weight;
  18.  
  19.         public Player(string name, int age, float weight)
  20.         {
  21.             _name = name;
  22.  
  23.             if (age >= 100 || age <= 0)
  24.             {
  25.                 _age = 0;
  26.             }
  27.             else
  28.             {
  29.                 _age = age;
  30.             }
  31.  
  32.             _weight = weight;
  33.         }
  34.  
  35.         public Player()
  36.         {
  37.             _name = "none";
  38.             _age = 0;
  39.             _weight = 0;
  40.         }
  41.  
  42.         public void OutputInformation()
  43.         {
  44.             Console.WriteLine($"Имя:{_name}\nВозраст:{_age}\nВес:{_weight}");
  45.         }
  46.     }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement