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 App2b
- {
- class Human : Introducable
- {
- protected string name;
- protected int age;
- private double temp;
- private string[] friends = new string[5];
- public static int counter = 0;
- private static string nationality = "Bugarian";
- public const double PI = 3.14;
- public static readonly double onlyRead = 5.4;
- private string info;
- public enum BrainSize {
- Small = 1300, Normal = 1350, Large = 1400
- }
- private Brain brain;
- // public enum BrainSize {
- // small = 1350, middle = 1400, large = 1450
- // };
- public static string Nationality
- {
- get { return nationality; }
- set { nationality = value; }
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- public int Age
- {
- get { return age; }
- set { age = value; }
- }
- public double Balance
- {
- get {return name.Length * 2 * 2;}
- }
- static Human() // a static constructor must be parametreess
- {
- onlyRead = 2.71;
- }
- public Human()
- : this("Default", 0, Human.BrainSize.Normal)
- {
- // this.name = "Default";
- // this.age = 0;
- }
- public Human(string name, int age, Human.BrainSize size)
- {
- this.name = name;
- this.age = age;
- counter++;
- // onlyRead = 2.71; // non static
- brain = new Brain(size);
- }
- public Human(int age, string name, params string[] friends)
- : this(name, age, Human.BrainSize.Normal)
- {
- // this.name = name;
- // this.age = age;
- int i = 0;
- foreach (string friend in friends)
- {
- this.friends[i] = friend;
- i++;
- }
- }
- public virtual void IntroduceYourSelf()
- {
- Console.WriteLine("My name is {0}. I am {1} years old! My Balance is {2}. My nationality is {3}. And I am {4}. And my brain tells me I am {5}", name, age, Balance, nationality, GetMyFeelings(), brain.Think());
- }
- public void IntroduceYourSelf(string verbous)
- {
- IntroduceYourSelf();
- Console.WriteLine("I am {0}", verbous);
- }
- public string GetFriendName(int index)
- {
- return friends[index];
- }
- public static double CalculateNationlIncome()
- {
- return counter * 10000;
- }
- public void Listen(string info)
- {
- this.info = info;
- }
- public string Talk()
- {
- return info;
- }
- private string GetMyFeelings()
- {
- if (age > 50) {
- return "sad";
- }
- return "happy";
- }
- private class Brain
- {
- private Human.BrainSize size;
- public Human.BrainSize Size
- {
- get { return size; }
- set { size = value; }
- }
- public Brain()
- : this(Human.BrainSize.Normal)
- { }
- public Brain(Human.BrainSize size)
- {
- this.size = size;
- }
- public string Think()
- {
- if (size >= Human.BrainSize.Normal) {
- return "Smart";
- }
- return "Dumm";
- }
- }
- // public abstract void Run();
- /*
- public string GetName()
- {
- return name;
- }
- public void SetName(string name)
- {
- this.name = name;
- }
- public int GetAge()
- {
- return age;
- }
- public void SetAge(int age)
- {
- this.age = age;
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement