Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- Training timetable1 = new Training("First Training");
- Console.WriteLine(timetable1.IsPractical());
- timetable1.Add(new Practice("Practical lesson 1.", "Demonstrate Inheritance using multiple classes.", "Lecture 1. Inheritance"));
- Console.WriteLine(timetable1.IsPractical());
- timetable1.Add(new Lecture("Lecture 1.", "Inheritance"));
- Console.WriteLine(timetable1.IsPractical());
- }
- }
- abstract class TrainingManagement
- {
- public string Description { get; set; }
- protected TrainingManagement(string description)
- {
- Description = description;
- }
- class Training : TrainingManagement
- {
- private Lesson[] _timetable;
- public Training(string description):base(description)
- {
- _timetable = new Lesson[0];
- }
- public void Add(Lesson lesson)
- {
- if (lesson != null)
- {
- Array.Resize(ref _timetable, _timetable.Length + 1);
- _timetable[_timetable.Length - 1] = lesson;
- }
- }
- public bool IsPractical()
- {
- if (_timetable == null || _timetable.Length==0) return false;
- else
- {
- foreach(Lesson item in _timetable)
- {
- if (item as Practice == null) return false;
- }
- }
- return true;
- }
- }
- abstract class Lesson : TrainingManagement
- {
- protected Lesson(string description) : base(description) { }
- }
- class Lecture : Lesson
- {
- public string Theme { get; set; }
- public Lecture(string description, string theme): base(description)
- {
- Theme = theme;
- }
- }
- class Practice : Lesson
- {
- public string TaskCondition { get; set; }
- public string SolutionCondition { get; set; }
- public Practice(string description, string task, string solution): base(description)
- {
- TaskCondition = task;
- SolutionCondition = solution;
- }
- }
Add Comment
Please, Sign In to add comment