Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text555 #16

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 60 additions & 11 deletions SRSDEMO/SRSDEMO.UI.Console/SRS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class SRS
//课程列表
public static ScheduleOfClasses scheduleOfClasses =
new ScheduleOfClasses("SP2009");
public static ScheduleOfClasses scheduleOfClasses1 =
new ScheduleOfClasses("SM2009");
//练习1,增加第二学期课表
public static ScheduleOfClasses scheduleOfClasses2 = new ScheduleOfClasses("SM2009");

//教授、学生、课程列表
public static List<Professor> faculty; // Generic List of Professors
public static List<Student> studentBody; // Generic List of Students
Expand Down Expand Up @@ -204,7 +205,8 @@ static void Main(string[] args)
// Semester is finished (boy, that was quick!). Professors
// assign grades.

sec1.PostGrade(s1, "C+");
//练习1,令学生s1的c1课程选修不及格
sec1.PostGrade(s1, "E");
sec1.PostGrade(s3, "A");
sec2.PostGrade(s2, "B+");
sec7.PostGrade(s2, "A-");
Expand Down Expand Up @@ -241,21 +243,68 @@ static void Main(string[] args)
Console.WriteLine("");
s3.Display();

//练习14.2
//练习1
Section sec2_1, sec2_2, sec2_3, sec2_4, sec2_5;

// 通过调用Course对象的ScheduleSection方法生成一个Section对象,相当于给某门课建立一个排课

sec2_1 = c1.ScheduleSection("M", "8:10 - 10:00 PM", "GOVT101", 30);
sec2_1 = c1.ScheduleSection("W", "6:10 - 8:00 PM", "GOVT202", 30);
scheduleOfClasses1.AddSection(sec1);
scheduleOfClasses1.AddSection(sec2);
//题2:让s1选sec2
EnrollFlags result = sec2_1.Enroll(s1);
sec2_2 = c2.ScheduleSection("TU", "8:10 - 10:00 PM", "GOVT102", 30);
sec2_3 = c3.ScheduleSection("W", "8:10 - 10:00 PM", "GOVT103", 30);
sec2_4 = c4.ScheduleSection("TH", "8:10 - 10:00 PM", "GOVT104", 30);
sec2_5 = c5.ScheduleSection("F", "8:10 - 10:00 PM", "GOVT105", 30);

//将Section加入到选课列表中

scheduleOfClasses2.AddSection(sec2_1);
scheduleOfClasses2.AddSection(sec2_2);
scheduleOfClasses2.AddSection(sec2_3);
scheduleOfClasses2.AddSection(sec2_4);
scheduleOfClasses2.AddSection(sec2_5);

//设定每门课的教师

p3.AgreeToTeach(sec2_1);
p2.AgreeToTeach(sec2_2);
p1.AgreeToTeach(sec2_3);
p3.AgreeToTeach(sec2_4);
p1.AgreeToTeach(sec2_5);

Console.WriteLine("\n The second semester! \n");


//模拟学生第二学期选课

//将学生s1的课程c1第一学期的成绩修改为E,这代表学生s1没通过课程c1
Console.WriteLine("Student " + s1.Name +
" is attempting to enroll in " +
sec2_2.ToString());

EnrollFlags status1 = sec2_2.Enroll(s1);

//题3:
ReportStatus(status1);

Console.WriteLine("");

//学生s3的课程c1第一学期的成绩是A。课程通过,s3可以选择课程c2

Console.WriteLine("Student " + s3.Name +
" is attempting to enroll in " +
sec2_2.ToString());

//题4:
status1 = sec2_2.Enroll(s3);

ReportStatus(status1);


//第二学期课表
Console.WriteLine("");
Console.WriteLine("====================");
Console.WriteLine("Schedule of Classes(the second semester):");
Console.WriteLine("====================");
Console.WriteLine("");
scheduleOfClasses2.Display();



Console.ReadKey();
Expand Down
37 changes: 31 additions & 6 deletions SRSDEMO/SRSDEMO.UI.Console/model/Course.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public Course(string cNo, string cName, double credits) {
// Auto-implemented properties.
//-------------------------------

public static int sectionnum = 0;
public string CourseNumber { get; set; }
public string CourseName { get; set; }
public double Credits { get; set; }
Expand Down Expand Up @@ -76,8 +77,16 @@ public override string ToString() {

//**************************************
//
public void AddPrerequisite(Course c) {
Prerequisites.Add(c);
public void AddPrerequisite(Course c)
{
if (this != c)
{
Prerequisites.Add(c);
}
else
{
Console.WriteLine("�γ̱����������Լ������޿Σ�����");
}
}

//**************************************
Expand All @@ -97,12 +106,28 @@ public Section ScheduleSection(string day, string time, string room,
int capacity) {
// Create a new Section (note the creative way in
// which we are assigning a section number) ...
Section s = new Section(OfferedAsSection.Count + 1,
day, time, this, room, capacity);

//��ϰ4 ��Ϊ�˱�֤ѡ�κŶ���һ��
sectionnum = sectionnum + 1;
Section s = new Section(sectionnum,
day, time, this, room, capacity);

// ... and then add it to the List
OfferedAsSection.Add(s);

return s;
}



//��ϰ4��
public void CancelSection(Section s)
{
//�γ̴�ѡ�������Ƴ�
OfferedAsSection.Remove(s);
//ѡ�����ѡ�α����Ƴ�
s.OfferedIn.SectionsOffered.Remove(s.RepresentedCourse.CourseNumber +
" - " + s.SectionNumber);

Console.WriteLine("�γ����Ƴ�ѡ�α���");
}
}
37 changes: 33 additions & 4 deletions SRSDEMO/SRSDEMO.UI.Console/model/Professor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,39 @@ public void DisplayTeachingAssignments() {

//**************************************
//
public void AgreeToTeach(Section s) {
Teaches.Add(s);

// We need to link this bidirectionally.
s.Instructor = this;
//��ϰ3��
public void AgreeToTeach(Section s)
{
bool isSameTime = true;

for (int i = 0; i < Teaches.Count; i++)
{
if (Teaches[i].OfferedIn == s.OfferedIn)
{
if (Teaches[i].DayOfWeek == s.DayOfWeek)
{
if (Teaches[i].TimeOfDay == s.TimeOfDay)
{
isSameTime = false;
}
else continue;
}
else continue;
}
else continue;
}

if (isSameTime)
{
Teaches.Add(s);
// We need to link this bidirectionally.
s.Instructor = this;
}
else
{
Console.WriteLine("һλ���ڲ�����ͬһ���ͬһʱ�̽������ſΣ�");
}

}
}
Loading