Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp23
- {
- class Program
- {
- static void Main(string[] args)
- {
- Cat cat = new Cat("Tom", 10, 2, 0.6f);
- cat.Age = 9;
- cat.Weight = 7;
- cat.Meow();
- }
- }
- class Cat
- {
- public string Name = "Dosya";
- public int age = 3;
- public int Height = 1;
- public float tailLength = 0.3f;
- public Cat()
- {
- Name = "Vasya";
- }
- public Cat(string Name, int age, int Height, float tailLength)
- {
- this.Name = Name;
- this.age = Age;
- //this.Weight = Weight;
- this.Height = Height;
- this.tailLength = tailLength;
- }
- public int Age
- {
- get { return age; }
- set { age = value; }
- }
- public int Weight
- {
- get;
- set;
- }
- public void Meow()
- {
- Console.WriteLine("Мое имя: "+ Name + ", мне " + age + " лет," + " рост: " + Height + " локоть, " + "вес: " + Weight + " кило, " + "длина хвоста: " + tailLength + " метра.");
- }
- }
- // Если переделать в struct, появляется ошибка о том, что в структуре не могут содержаться инициализаторы полей (переменных класса).
- }
Advertisement
Add Comment
Please, Sign In to add comment