exceptions added for user input
This commit is contained in:
+7
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user