Я пытался придумать правильный способ сохранить имя и номера инструкторов в соответствующих объектах класса
Teacher _teacher;Student [] Students;
Они находятся внутри класса с именем Course.
Как только я соберу все необходимые ответы, мне нужно создать экземпляр объекта Course, значения которого соответствуют конструктору Course,Я не могу понять, чтобы передать правильный тип данных, который требуется конструктору.
class Course
{
// Fields for a course - title, description, teacher, students
private string _title;
private string _description;
private Teacher _teacher = null;
private Student[] _students;
public Course(string title, string description, Teacher teacher, Student[] student)
{
_title = title;
_description = description;
_teacher = teacher;
_students = student;
}
public string Title
{
get { return _title; }
set { _title = value; }
}
public string Description
{
get { return _description; }
set { _description = value; }
}
public Teacher Instructor
{
get { return _teacher; }
set { _teacher = value; }
}
public Student[] Students
{
get { return _students; }
set { _students = value; }
}
}
}
public static void CreateCourse(Course _currentCourse)
{
Console.Clear();
Console.WriteLine("test");
if (_currentCourse != null )
{
Console.WriteLine("* Create Course *\r\n");
Console.WriteLine("Enter the course title: ");
string title = Console.ReadLine();
Validation.EmptyValidation(title,
"Please, do not leave the course title field empty!" +
"\r\nEnter the course title: ");
Console.WriteLine("Enter the course description: ");
string description = Console.ReadLine();
Validation.EmptyValidation(title,
"Please, do not leave the course description field empty!" +
"\r\nEnter the course description: ");
Console.WriteLine("Enter the course instructor: ");
string instructor = Console.ReadLine();
Console.WriteLine("Enter the number of students in the course: ");
string students = Console.ReadLine();
int.TryParse(students, out int stu);
}
}
class Student : Person
{
// Field for a student grade.
int _grade;
// Student constructor
public Student(string name, string description, int age, int grade ) : base(name, description, age)
{
_grade = grade;
}
// Accessor & Mutator for the Student grade.
public int Grade
{
get { return _grade; }
set { _grade = value; }
}
}
class Teacher : Person
{
// Field for the teacher knowledge
private string[] _teacherKnowledge;
// Teacher constructor
public Teacher(string name, string description, int age, string[] teacherKnowledge) : base(name, description, age)
{
_teacherKnowledge = teacherKnowledge;
}
// Accessor & Mutator for the the Teacher knowledge
public string[] Knowledge
{
get { return _teacherKnowledge; }
set { _teacherKnowledge = value; }
}
}
Есть предложения?