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 WorldMI
- {
- class Person
- {
- private string name;
- private int age;
- private decimal balance;
- private string[] friends;
- private static int counter = 0;
- public const double PI = 3.14 * 2;
- public static readonly double only4Read = 2.71;
- public static int Counter
- {
- get { return counter; }
- }
- public string this[int i]
- {
- get { return friends[i]; }
- set { friends[i] = value; }
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- public int Age
- {
- get { return age; }
- set {
- if (value > 120 || value < 0) value = 0;
- age = value;
- }
- }
- static Person()
- {
- only4Read = 546;
- }
- public Person()
- :this("Default", 0)
- {
- //this.name = "Default";
- //this.age = 0;
- }
- // working horse
- public Person(string name, int age, decimal balance = 0.0M, params string[] friends)
- {
- this.name = name;
- this.age = age;
- this.balance = balance;
- this.friends = friends;
- counter++;
- // only4Read = age * 111;
- }
- public Person(int age, string name)
- :this(name, age)
- {
- //this.name = name;
- //this.age = age;
- }
- //public string GetName()
- //{
- // return name;
- //}
- //public void SetName(string name)
- //{
- // this.name = name;
- //}
- //public int GetAge()
- //{
- // return age;
- //}
- //public void SetAge(int age)
- //{
- // if(age > 120 || age < 0)
- // {
- // age = 0;
- // }
- // this.age = age;
- //}
- public void IntroduceYourSelf()
- {
- Console.WriteLine("My name is {0}. I am {1} years old! Last year I was {2} years old!", name, age, GetLastYearAge(age));
- CalculateNationalIncome();
- }
- private int GetLastYearAge(int age)
- {
- return age - 1;
- }
- public static double CalculateNationalIncome()
- {
- return counter * 1000;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement