-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed34e48
commit a682645
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""This module defines the basic structures necessary | ||
""" | ||
|
||
|
||
class Course: | ||
"""This represents Course""" | ||
|
||
def __init__(self, course_id: str, name: str) -> None: | ||
self.__course_id = course_id | ||
self.__name = name | ||
|
||
@property | ||
def name(self): | ||
"""This property returns name""" | ||
return self.__name | ||
|
||
@property | ||
def course_id(self): | ||
"""Course Id propert""" | ||
return self.__course_id | ||
|
||
|
||
class Student: | ||
""" | ||
This class Represents the student | ||
""" | ||
|
||
def __init__( | ||
self, | ||
student_id: str, | ||
name: str, | ||
) -> None: | ||
self.student_id = student_id | ||
self.name = name | ||
self.courses = [] | ||
|
||
def enroll_course(self, course: Course): | ||
"""We are enrolling student to a course""" | ||
self.courses.append(course) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
This test cases test the institute structures | ||
""" | ||
from learning.institute.structure import Course, Student | ||
|
||
def test_student_course(): | ||
"""Testing the basic functionality | ||
""" | ||
python_course = Course( | ||
"x123", | ||
"Python" | ||
) | ||
devops_course = Course( | ||
"x121", | ||
"DevOps" | ||
) | ||
cloud_course = Course( | ||
"x121", | ||
"DevOps" | ||
) | ||
student = Student( | ||
student_id = "s1001", | ||
name = "Abhay" | ||
) | ||
|
||
assert len(student.courses) == 0 | ||
# now lets enroll student to python | ||
student.enroll_course(python_course) | ||
assert len(student.courses) == 1 | ||
student.enroll_course(devops_course) | ||
assert len(student.courses) == 2 | ||
student.enroll_course(cloud_course) | ||
assert len(student.courses) == 3 |