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;
- 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;
- }
- }
- 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;
- }
- 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));
- }
- private int GetLastYearAge(int age)
- {
- return age - 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement