Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.8 kB
1
Indexable
Never
from Student import Student
from Note import Note, NoteValue, ExamType, Term
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 delete_student(self, id):

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


    def show_students_list(self):

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



    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.uuid == id:
                return student


    def show_notes_by_uuid(self, uuid):

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

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





service = StudentService()


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


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

student.add_note(note)

service.show_students_list()

note2 = Note(NoteValue.FIVE_ZERO, ExamType.TEST, Term.THIRD, uuid.uuid4(), date.today())

student.add_note(note2)
service.show_students_list()

print('-------')

print(service.show_student_by_id(student.uuid))


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

note = Note(NoteValue.FOUR_HALF, ExamType.EXAM, Term.FIRST, uuid.uuid4(), date.today())
student.add_note(note)
service.show_students_list()