Advertisement
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 ConsoleApplication56
- {
- class Program
- {
- static void Main(string[] args)
- {
- Student student = new Student(17);
- Console.WriteLine(student.GetAdultHood);
- Console.WriteLine(student.SomeValue = 4);
- student.ShowCount();
- }
- }
- class Student
- {
- private int _age;
- private int _getterCount = 0;
- private int _setterCount = 0;
- private int _someValue;
- public Student(int age)
- {
- _age = age;
- }
- public int CheckAge
- {
- get
- {
- _getterCount += 1;
- return _age;
- }
- }
- public int SomeValue
- {
- get { return SomeValue; }
- set
- {
- _setterCount += 1;
- _someValue = value;
- }
- }
- public string GetAdultHood
- {
- get
- {
- _getterCount += 1;
- if (_age >= 18)
- return "Совершеннолетний";
- else
- return "Несовершеннолетний";
- }
- }
- public void ShowCount()
- {
- Console.WriteLine(_getterCount);
- Console.WriteLine(_setterCount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement