From 55a1e7c9b998c9b9459aceec134f8909134b2392 Mon Sep 17 00:00:00 2001 From: tstst334 Date: Tue, 30 Jul 2019 07:56:44 -0700 Subject: [PATCH 1/5] add main --- main.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 From 44a5fbc4b7961a5635f7dc071f9683168f0c1403 Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Wed, 31 Jul 2019 16:38:47 +0200 Subject: [PATCH 2/5] started main and fixed issue #7 --- main.py | 11 +++++++++++ subject.py | 7 +++++++ user_IO.py | 6 +++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index e69de29..b340ca6 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,11 @@ +import subject +import user_IO + +subjects = [] +while True: + user_input = user_IO.user_input() + if user_input[0] == "input": + if user_input[1] == "grade": + subject_edit = subject.get_subject(subjects, user_input[2]) + if subject_edit: + subject_edit.add_grade(user_input[3], subject.Grade(user_input[4], user_input[5])) diff --git a/subject.py b/subject.py index 6e19562..9935cbe 100644 --- a/subject.py +++ b/subject.py @@ -26,3 +26,10 @@ class Grade: self.grade = grade self.name = name self.date = date + + +def get_subject(liste, name): + for subject in liste: + if subject.name == name: + return subject + return None diff --git a/user_IO.py b/user_IO.py index 7fcc4d1..3595133 100644 --- a/user_IO.py +++ b/user_IO.py @@ -10,15 +10,15 @@ def user_input(): user_add = input() if user_add == "subject": subject = input("Which subject do you want to add? \n") - return "input", subject + return "input", "subject", subject elif user_add == "category": subject = input("To which subject do you want to add the category? \n") category = input("Which category do you want to add? \n") rating = float(input("Rating? \n")) - return "input", subject, category, rating + return "input", "category", subject, category, rating elif user_add == "grade": subject = input("To which subject do you want to add the grade? \n") category = input("To which category do you want to add it? \n") grade = input("Grade? \n") grade_name = input("What's the name of the grade? \n") - return "input", subject, category, grade, grade_name + return "input", "grade", subject, category, grade, grade_name From ad2fad6b292993030d62bb90a09e350cb7f99b31 Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Wed, 31 Jul 2019 19:36:22 +0200 Subject: [PATCH 3/5] error handling (issue n#9) --- main.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index b340ca6..209796f 100644 --- a/main.py +++ b/main.py @@ -2,10 +2,21 @@ import subject import user_IO subjects = [] -while True: - user_input = user_IO.user_input() - if user_input[0] == "input": - if user_input[1] == "grade": - subject_edit = subject.get_subject(subjects, user_input[2]) - if subject_edit: - subject_edit.add_grade(user_input[3], subject.Grade(user_input[4], user_input[5])) +try: + while True: + user_input = user_IO.user_input() + if user_input[0] == "input": + if user_input[1] == "grade": + subject_edit = subject.get_subject(subjects, user_input[2]) + if subject_edit: + subject_edit.add_grade(user_input[3], subject.Grade(user_input[4], user_input[5])) + elif user_input[1] == "category": + subject_edit = subject.get_subject(subjects, user_input[2]) + if subject_edit: + subject_edit.add_grade_category(user_input[3], user_input[4]) + elif user_input[1] == "subject": + subjects.append(subject.Subject(user_input[2], _, _)) + raise SystemError + +except Exception as e: + print('ERROR' + str(e)) \ No newline at end of file From 3f0b08710018c73429333cbda69909a83f75471e Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Wed, 31 Jul 2019 20:02:15 +0200 Subject: [PATCH 4/5] main --- main.py | 5 ++++- user_IO.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 209796f..8e36f6b 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,10 @@ try: if subject_edit: subject_edit.add_grade_category(user_input[3], user_input[4]) elif user_input[1] == "subject": - subjects.append(subject.Subject(user_input[2], _, _)) + subjects.append(subject.Subject(user_input[2], user_input[3], user_input[4])) + elif user_input[0] == "output": + subject_get = subject.get_subject(subjects, user_input[1]) + user_IO.user_output(subject_get.) raise SystemError except Exception as e: diff --git a/user_IO.py b/user_IO.py index 3595133..91b6da5 100644 --- a/user_IO.py +++ b/user_IO.py @@ -10,7 +10,17 @@ def user_input(): user_add = input() if user_add == "subject": subject = input("Which subject do you want to add? \n") - return "input", "subject", subject + main_subject = input("Is this subject a main subject (Hauptfach)[y/n]? \n") + if main_subject == 'y': + main_subject = True + elif main_subject == 'n': + main_subject = False + oral_exam = input("Will there be an oral exam in this subject [y/n]? \n") + if oral_exam == 'y': + oral_exam = True + elif oral_exam == 'n': + oral_exam = False + return "input", "subject", subject, main_subject, oral_exam elif user_add == "category": subject = input("To which subject do you want to add the category? \n") category = input("Which category do you want to add? \n") @@ -22,3 +32,8 @@ def user_input(): grade = input("Grade? \n") grade_name = input("What's the name of the grade? \n") return "input", "grade", subject, category, grade, grade_name + + +def user_output(i): + # just filled with some standard output, has to be filled further + print(i) \ No newline at end of file From e4d4acb345199d7cc9b0adf1d61ad6c64d59cdd9 Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Wed, 31 Jul 2019 20:03:22 +0200 Subject: [PATCH 5/5] main complete --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 8e36f6b..c238362 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,7 @@ try: subjects.append(subject.Subject(user_input[2], user_input[3], user_input[4])) elif user_input[0] == "output": subject_get = subject.get_subject(subjects, user_input[1]) - user_IO.user_output(subject_get.) + user_IO.user_output(subject_get.return_average_subject) raise SystemError except Exception as e: