exceptions added for user input

This commit is contained in:
2019-08-02 18:54:27 +02:00
parent 0cb5e2f73f
commit caf650eaef
4 changed files with 91 additions and 33 deletions
+7 -1
View File
@@ -1,4 +1,5 @@
from datetime import datetime as str_date
from exceptions import SubjectNotExistingException, CategoryNotExistingException
class Subject:
@@ -31,6 +32,11 @@ class Subject:
grade_sum += self.return_average_of_category(i)
return grade_sum / rating_sum
def category_existing(self, category):
if category in self.grades:
return True
raise CategoryNotExistingException
class Grade:
def __init__(self, grade, name, date=str(str_date.now())):
@@ -43,4 +49,4 @@ def get_subject(liste, name):
for subject in liste:
if subject.name == name:
return subject
return None
raise SubjectNotExistingException