Untitled

 avatar
unknown
python
2 years ago
1.3 kB
2
Indexable
import uuid

class Ocena():

    def __init__(self, ocena, typ_oceny, termin, data_wpisu):
        self.UUID = uuid.uuid4()
        self.ocena = ocena
        self.typ_oceny = typ_oceny
        self.termin = termin
        self.data_wpisu = data_wpisu
        self.dopuszczalna_ocena = [2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0]


    def jest_poprawna(self, ocena):
        if self.ocena in self.dopuszczalna_ocena:
            return True
        else:
            return False


class Student():

    def __init__(self, imie, nazwisko, lista_ocen):
        self.UUID = uuid.uuid4()
        self.imie = imie
        self.nazwisko = nazwisko
        self.lista_ocen = lista_ocen
        self.nowa_ocena = None

    def wyswietlenie_listy_ocen(self):
        print(self.lista_ocen)

    def dodawanie_nowej_oceny(self, nowa_ocena):
        if Ocena.jest_poprawna(self.nowa_ocena):
            self.lista_ocen.append(nowa_ocena)
        else:
            raise ValueError("Nieprawidłowy format oceny!")



class Program:
    pass



student1 = Student("Anna", "Nowak", [])
print(vars(student1))

student1.wyswietlenie_listy_ocen()
student1.dodawanie_nowej_oceny(3.0)
student1.wyswietlenie_listy_ocen()
student1.dodawanie_nowej_oceny(4.5)
student1.wyswietlenie_listy_ocen()





Editor is loading...