Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
820 B
2
Indexable
Never
from Student import Student

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