Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
2.1 kB
2
Indexable
Never
from Student import Student
from Note import *
import uuid
from datetime import date

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, surname):

        for student in self.students_list:
            if student.surname == surname:
                student.notes.append(note)


    def show_notes_by_surname(self, surname):

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

                print(f"Student: {student.name} {student.surname}, notes: {student.notes}")



service = StudentService()


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

student = Student('Marta', 'Sommer')
service.add_student(student)
#service.show_students_list()

student = Student('Jakub', 'Rucki')
service.add_student(student)


service.show_students_list()

note = Note(NoteValue.FOUR_HALF, ExamType.TEST, Term.FIRST, uuid, date)

service.add_note(note, 'Rucki')
service.show_notes_by_surname('Rucki')

service.show_students_list()

note = Note(NoteValue.THREE_ZERO, ExamType.EXAM, Term.THIRD, uuid, date)

service.add_note(note, 'Sommer')
service.show_notes_by_surname('Sommer')

note = Note(NoteValue.FOUR_HALF, ExamType.TEST, Term.FIRST, uuid, date)
service.add_note(note, 'Sommer')
service.show_notes_by_surname('Sommer')