Advertisement
AziLif

Работа с классами

Jun 12th, 2025
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Player hunter = new Player("Кро-Кро", 987, 123.7f);
  10.  
  11.             hunter.ShowInfo();
  12.         }
  13.     }
  14.  
  15.     class Player
  16.     {
  17.         private string _name;
  18.         private int _age;
  19.         private float _bodyWeight;
  20.  
  21.         public Player(string name, int age, float bodyWeight)
  22.         {
  23.             _name = name;
  24.             _age = age;
  25.             _bodyWeight = bodyWeight;
  26.         }
  27.  
  28.         public void ShowInfo()
  29.         {
  30.             Console.WriteLine($"Наш игрок: \nЕго имя - {_name}, возраст - {_age}, масса тела - {_bodyWeight} ");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement