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 _3Lab
- {
- class Program
- {
- static void Main(string[] args)
- {
- Enrolee enrolee = new Enrolee("Ivan", 200, "Повар");
- Student student = new Student();
- enrolee = (Enrolee)student;
- student = (Student)enrolee;
- if (student == null)
- {
- Console.WriteLine("Ошибка!");
- }
- else if (student != null)
- Console.WriteLine(student.Name);
- }
- }
- class Enrolee
- {
- public string Name { get; set; }
- public int EntrancePoints { get; set; }
- public string Specialization { get; set; }
- public Enrolee()
- {
- Name = "No name";
- EntrancePoints = 0;
- Specialization = "No xxx";
- }
- public Enrolee(string name ,int entrancePoints, string specialization)
- {
- Name = name;
- EntrancePoints = entrancePoints;
- Specialization = specialization;
- }
- public void EnterInfo()
- {
- Name = Console.ReadLine();
- EntrancePoints = Convert.ToInt32(Console.ReadLine());
- Specialization = Console.ReadLine();
- }
- }
- class Student : Enrolee
- {
- public bool RecordBook { get; set; }
- public int StudentID { get; set; }
- public Student()
- {
- RecordBook = true;
- ++StudentID;
- }
- public Student(string name, int entrancePoints, string specialization)
- : base(name, entrancePoints, specialization)
- {
- RecordBook = true;
- ++StudentID;
- }
- public Student(Enrolee enrolee)
- {
- RecordBook = true;
- ++StudentID;
- }
- public Student(string name, int entrancePoints, string specialization, bool recordBook, int studentID)
- : base(name, entrancePoints, specialization)
- {
- RecordBook = recordBook;
- StudentID = studentID;
- }
- public void SetDefault()
- {
- }
- //public Student(string name, int entrancePoints, string specialization)
- // : base(name, entrancePoints, specialization)
- //{
- //}
- }
- class Extrabudgetary : Student
- {
- public bool EducationСontract { get; set; }
- public Extrabudgetary(string name, int entrancePoints, string specialization, bool recordBook, int studentID, bool educationContract)
- : base(name, entrancePoints, specialization, recordBook, studentID)
- {
- EducationСontract = educationContract;
- }
- }
- class Budgetary : Student
- {
- public bool Stipend { get; set; }
- public Budgetary(string name, int entrancePoints, string specialization, bool recordBook, int studentID, bool stipend)
- : base(name, entrancePoints, specialization, recordBook, studentID)
- {
- Stipend = stipend;
- }
- }
- }
Add Comment
Please, Sign In to add comment