Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.5 kB
3
Indexable
Never
from Student import Student
from Note import Note

class StudentService:

    def __init__(self):
        self.students_list = []

    def add_student(self, student):

        self.students_list.append(student)

    def show_students_list(self):
        for student in self.students_list:
            print(student.__repr__())

    def delete_student(self, id):

        for student in self.students_list:
            if student.id == id:
                self.students_list.remove(student)


    def update_student(self, id, name, surname):

        for student in self.students_list:
            if student.id == id:
                student.name = name
                student.surname = surname

    def show_student_by_id(self, id):

        for student in self.students_list:
            if student.id == id:
                return student

    def add_note(self, note, id):

        available_notes = [2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]
        # term = ["FIRST", "SECOND", "THIRD", "BOARD_EXAM"]
        for student in self.students_list:
            if note in available_notes and student.id == id:
                student.notes.append(note)




    def show_notes_by_id(self, id):

        for student in self.students_list:
            if student.id == id:
                print(student)
                print(f"Student's data: {student}, list of notes: {student.show_notes()}")


service = StudentService()


student = ('Izabela', 'Greszta')
service.add_student(student)
service.show_students_list()