Advertisement
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;
- /*Вариант 2*/
- namespace SR5_Karabash_Radimir_BSE195_1
- {
- public class CourseWorkThemes
- {
- int Length;
- int count = 0;
- string[] Tutors;
- string[] Themes;
- public CourseWorkThemes(int Length,params string[] Tutors)
- {
- this.Length = Length;
- this.Tutors = Tutors;
- Themes = new string[Length];
- }
- public void Append(string Theme)
- {
- Themes[count] = Theme;
- count++;
- }
- public string this[int i]
- {
- get
- {
- return this.Themes[i];
- }
- }
- public string GetTutors()
- {
- string res = "Список научруков: \n\n";
- for (int i = 0; i < Tutors.Length; i++)
- {
- res = res + $"{i + 1}. {Tutors[i]}\n";
- }
- return res;
- }
- public override string ToString()
- {
- string res = "Список курсовых тем: \n\n";
- for (int i = 0; i < Themes.Length; i++)
- {
- res = res + $"{i+1}. {Themes[i]}\n";
- }
- return res;
- }
- }
- class Program
- {
- static Random generator = new Random();
- static void Main(string[] args)
- {
- try
- {
- do
- {
- string[] Tutors = new string[5] { "Шершаков", "Чуйкин", "Авдошин", "Баканов", "Самоненко" };
- int n;
- do Console.WriteLine("Введите количество курсовых тем: ");
- while (!int.TryParse(Console.ReadLine(), out n) | n <= 0);
- CourseWorkThemes courseWork = new CourseWorkThemes(n, Tutors);
- for (int i = 0; i < n; i++)
- {
- Console.WriteLine("Введите название курсовой: ");
- courseWork.Append(Console.ReadLine());
- }
- Console.WriteLine($"Рандомная курсовая: {courseWork[generator.Next(0, n)]}");
- Console.WriteLine(courseWork);
- Console.WriteLine(courseWork.GetTutors());
- } while (true);
- }
- catch (Exception e)
- {
- Console.WriteLine($"Ошибка: {e.Message}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement