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 ConsoleApplication49
- {
- class MyClass
- {
- private int num, min, max;
- public MyClass(int a,int b)
- {
- min = a;
- max = b;
- code = (max + min) / 2;
- }
- public int code
- {
- get
- {
- return num;
- }
- set
- {
- if (value < min) num = min;
- else if (value > max) num = max;
- else num = value;
- }
- }
- }
- class UsingProbs
- {
- static void Main()
- {
- MyClass obj = new MyClass(1, 9);
- Console.WriteLine("Свойство code:" + obj.code);
- obj.code = 7;
- Console.WriteLine("Свойство code:" + obj.code);
- obj.code = 20;
- Console.WriteLine("Свойство code:" + obj.code);
- obj.code = -10;
- Console.WriteLine("Свойство code:" + obj.code);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement