Advertisement
wingman007

OOP2016FullTimeInheritanceStudent

Apr 19th, 2016
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace World3a3b
  8. {
  9.     class Student : Person
  10.     {
  11.         // public string Name { get; set; }
  12.         private int fNumber;
  13.  
  14.         public int FNumber
  15.         {
  16.             get { return fNumber; }
  17.             set { fNumber = value; }
  18.         }
  19.         /*
  20.         public Student()
  21.             :base()
  22.         { }
  23.         */
  24.        
  25.         public Student(string name, int age, int fNumber)
  26.             :base(name, age) // :base()
  27.         {
  28.             this.fNumber = fNumber;
  29.         }
  30.  
  31.         // public void IntroduceYourSelfStudent()
  32.         // public new void IntroduceYourSelf() // hiding
  33.         public override void IntroduceYourSelf() // override
  34.         {
  35.             Console.WriteLine("---------- Student ------------------");
  36.             // Console.WriteLine("My name is {0}. I am {1} yers old. My balance is {2}. I am {3}. fNumber = {4}", name, age, Balance, nationality, fNumber);
  37.             base.IntroduceYourSelf();
  38.             Console.WriteLine("fNumber = {0}", fNumber);
  39.             Console.WriteLine("----------------- End -------------");
  40.         }
  41.  
  42.         public override string ToString()
  43.         {
  44.             return base.ToString() + " fNumber = " + fNumber;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement