-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
122 lines (102 loc) · 3.62 KB
/
Copy pathMain.py
File metadata and controls
122 lines (102 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""
File: main.py
Description: This script demonstrates the creation and usage of the School, Course, Student, and Staff classes.
It runs a sequence of tests covering adding/removing entities, instructor assignments,
student enrolment and drop logic, and staff course assignments.
Author: Anush Shirantha De Costa
ID: 110454712
Username: deyay064
This is my own work as defined by the University's Academic Misconduct Policy.
"""
from School import School
from Course import Course
from Student import Student
from Staff import Staff
import datetime
def test_school():
"""
Test add/remove functionality in School.
"""
school = School("School of IT")
student = Student("S1001", "Anush", "De Costa",
datetime.date(2000, 1, 1))
staff = Staff("EMP100", "Reid", "Honan",
datetime.date(1980, 5, 20),
"reid@uni.edu", "0412345678", "IT Department")
course = Course("COMP1001", "Python Programming", "SP3 2025", 3)
print("\n--- School Tests ---")
school.add_student(student)
school.add_student(student) # duplicate
school.remove_student(student)
school.remove_student(student) # not found
print("\n--------------------")
school.add_staff(staff)
school.add_staff(staff) # duplicate
school.remove_staff(staff)
school.remove_staff(staff) # not found
print("\n--------------------")
school.add_course(course)
school.add_course(course) # duplicate
school.remove_course(course)
school.remove_course(course) # not found
print("\nSchool Summary:")
print(school)
def test_course():
"""
Test instructor assignment and __str__ of Course.
"""
staff = Staff("EMP100", "Reid", "Honan", datetime.date(1980, 5, 20),
"reid@uni.edu", "0412345678", "IT Department")
course = Course("COMP1001", "Python Programming", "SP3 2025", 3)
print("\n--- Course Tests ---")
print(course)
course.set_instructor(staff)
print("\nAfter set_instructor:")
print(course)
def test_student_course():
"""
Test bidirectional enrol and drop between Student and Course.
"""
student = Student("S1001", "Anush", "De Costa",
datetime.date(2000, 1, 1))
course = Course("COMP1001", "Python Programming", "SP3 2025", 3)
print("\n--- Student and Course Tests ---")
print(student)
print("\n--------------------")
student.enrol(course)
student.enrol(course) # duplicate
print("\n--------------------")
student.drop(course)
student.drop(course) # not enrolled
print("\nStudent __str__:")
print(student)
def test_staff_course():
"""
Test assignment and removal of Courses for Staff.
"""
staff = Staff("EMP100", "Reid", "Honan",
datetime.date(1980, 5, 20),
"reid@uni.edu", "0412345678", "IT Department")
course = Course("COMP1001", "Python Programming", "SP3 2025", 3)
print("\n--- Staff and Course Tests ---")
print(staff)
print("\n--------------------")
staff.assign_course(course)
staff.assign_course(course) # duplicate
print("\n--------------------")
staff.remove_course(course)
staff.remove_course(course) # not assigned
print("\nStaff __str__:")
print(staff)
def main():
"""
Runs all test sequences in order to verify functionality of each class.
"""
print("\n=== Demo: Basic Programming Classes ===")
test_school()
test_course()
test_student_course()
test_staff_course()
print("\n=== Demo Complete ===")
if __name__ == "__main__":
main()