Advertisement
Margoshinka

classes

Mar 11th, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.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 SYATP2_2
  8. {
  9.     [Serializable]
  10.     public class Student
  11.     {
  12.         public string name;
  13.         public string lastname;
  14.         public string faculty;
  15.         public string Name
  16.         {
  17.             get
  18.             { return name; }
  19.             set
  20.             {
  21.                 name = value;
  22.             }
  23.         }
  24.         public string Lastname
  25.         {
  26.             get
  27.             { return lastname; }
  28.             set
  29.             {
  30.                 lastname = value;
  31.             }
  32.         }
  33.         public string Faculty
  34.         {
  35.             get
  36.             { return faculty; }
  37.             set
  38.             {
  39.                 faculty = value;
  40.             }
  41.         }
  42.  
  43.  
  44.         public Student()
  45.         {
  46.             Name = "";
  47.             Lastname = "";
  48.             Faculty = "";
  49.         }
  50.  
  51.         public virtual List<(string,string)> getField()
  52.         {
  53.            return  new List<(string, string)> {("Name", Name),("Lastname", Lastname),("Faculty", Faculty) } ;      
  54.         }
  55.         public Student(string n, string l, string f)
  56.         {
  57.             Name = n;
  58.             Lastname = l;
  59.             Faculty = f;
  60.         }
  61.        
  62.         public override string ToString()
  63.         {
  64.             return $"Имя = {Name}, фамилия = {Lastname}, факультет = {Faculty}";
  65.         }
  66.     }
  67. }
  68. using System;
  69. using System.Collections.Generic;
  70. using System.Linq;
  71. using System.Text;
  72. using System.Threading.Tasks;
  73.  
  74. namespace SYATP2_2
  75. {
  76.    public class Master:Student
  77.     {
  78.         public string diplomaNumber;
  79.         public string DiplomaNumber
  80.         {
  81.             get
  82.             { return diplomaNumber; }
  83.             set
  84.             {
  85.                 diplomaNumber = value;
  86.             }
  87.         }
  88.         public override List<(string, string)> getField()
  89.         {
  90.             return new List<(string, string)> { ("Name", Name), ("Lastname", Lastname), ("Faculty", Faculty), ("DiplomaNumber" , DiplomaNumber)};
  91.         }
  92.         public Master() : base()
  93.         {
  94.             DiplomaNumber = "";
  95.         }
  96.  
  97.  
  98.         public Master(string n, string l, string f, string d):base(n,l,f)
  99.         {
  100.             DiplomaNumber = d;
  101.         }
  102.     }
  103. }
  104.  
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement