Torgach

3Lab

Mar 24th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 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 _3Lab
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Enrolee enrolee = new Enrolee("Ivan", 200, "Повар");
  14.  
  15.             Student student = new Student();
  16.  
  17.             enrolee = (Enrolee)student;
  18.  
  19.             student = (Student)enrolee;
  20.            
  21.             if (student == null)
  22.             {
  23.                 Console.WriteLine("Ошибка!");
  24.             }
  25.             else if (student != null)
  26.                 Console.WriteLine(student.Name);
  27.         }
  28.     }
  29.  
  30.     class Enrolee
  31.     {
  32.         public string Name { get; set; }
  33.  
  34.         public int EntrancePoints { get; set; }
  35.  
  36.         public string Specialization { get; set; }
  37.  
  38.         public Enrolee()
  39.         {
  40.             Name = "No name";
  41.             EntrancePoints = 0;
  42.             Specialization = "No xxx";
  43.         }
  44.  
  45.         public Enrolee(string name ,int entrancePoints, string specialization)
  46.         {
  47.             Name = name;
  48.             EntrancePoints = entrancePoints;
  49.             Specialization = specialization;
  50.         }
  51.  
  52.         public void EnterInfo()
  53.         {
  54.             Name = Console.ReadLine();
  55.  
  56.             EntrancePoints = Convert.ToInt32(Console.ReadLine());
  57.  
  58.             Specialization = Console.ReadLine();
  59.  
  60.         }
  61.     }
  62.  
  63.     class Student : Enrolee
  64.     {
  65.         public bool RecordBook { get; set; }
  66.         public int StudentID { get; set; }
  67.  
  68.         public Student()
  69.         {
  70.             RecordBook = true;
  71.             ++StudentID;
  72.         }
  73.         public Student(string name, int entrancePoints, string specialization)
  74.             : base(name, entrancePoints, specialization)
  75.         {
  76.             RecordBook = true;
  77.             ++StudentID;
  78.         }
  79.  
  80.         public Student(Enrolee enrolee)
  81.         {
  82.             RecordBook = true;
  83.             ++StudentID;
  84.         }
  85.  
  86.         public Student(string name, int entrancePoints, string specialization, bool recordBook, int studentID)
  87.             : base(name, entrancePoints, specialization)
  88.         {
  89.             RecordBook = recordBook;
  90.             StudentID = studentID;
  91.         }
  92.         public void SetDefault()
  93.         {
  94.  
  95.         }
  96.  
  97.         //public Student(string name, int entrancePoints, string specialization)
  98.         //    : base(name, entrancePoints, specialization)
  99.         //{
  100.  
  101.  
  102.         //}
  103.     }
  104.  
  105.     class Extrabudgetary : Student
  106.     {
  107.         public bool EducationСontract { get; set; }
  108.  
  109.         public Extrabudgetary(string name, int entrancePoints, string specialization, bool recordBook, int studentID, bool educationContract)
  110.             : base(name, entrancePoints, specialization, recordBook, studentID)
  111.         {
  112.             EducationСontract = educationContract;
  113.         }
  114.     }
  115.  
  116.     class Budgetary : Student
  117.     {
  118.         public bool Stipend { get; set; }
  119.  
  120.         public Budgetary(string name, int entrancePoints, string specialization, bool recordBook, int studentID, bool stipend)
  121.             : base(name, entrancePoints, specialization, recordBook, studentID)
  122.         {
  123.             Stipend = stipend;
  124.         }
  125.     }
  126. }
  127.  
Add Comment
Please, Sign In to add comment