From b8aef9ed66c82e33ec4b76ccab676490339ad2a4 Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Wed, 31 Jul 2019 19:59:11 +0200 Subject: [PATCH 1/2] Merge branch 'master' of /home/lars/PycharmProjects/grade-program with conflicts. --- main.py | 25 +++++++++++++++++++++++++ user_IO.py | 22 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..8e36f6b --- /dev/null +++ b/main.py @@ -0,0 +1,25 @@ +import subject +import user_IO + +subjects = [] +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], 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: + print('ERROR' + str(e)) \ No newline at end of file diff --git a/user_IO.py b/user_IO.py index 4fa37a9..91b6da5 100644 --- a/user_IO.py +++ b/user_IO.py @@ -1,4 +1,5 @@ def user_input(): + print("Hi User, \n do you want to edit your grades?") todo = input("Ok, do you want to see them or to edit them? [see/edit]\n") if todo == "see": print("Which subject do you want to know the information?") @@ -9,15 +10,30 @@ def user_input(): user_add = input() if user_add == "subject": subject = input("Which subject do you want to add? \n") - return "input", 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") 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 + + +def user_output(i): + # just filled with some standard output, has to be filled further + print(i) \ No newline at end of file From 15295d92ad7d08895fae34dd7f7c13b0aa2f4ea7 Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Fri, 2 Aug 2019 14:06:58 +0200 Subject: [PATCH 2/2] main change names --- main.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 3d7b3f9..4c44759 100644 --- a/main.py +++ b/main.py @@ -5,19 +5,30 @@ subjects = [] 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]) + input_or_output = user_input[0] + if input_or_output == "input": + _edit = user_input[1] + _subject = user_input[2] + if _edit == "grade": + _category = user_input[3] + _grade = user_input[4] + _grade_name = user_input[5] + subject_edit = subject.get_subject(subjects, _subject) 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]) + subject_edit.add_grade(_category, subject.Grade(_grade, _grade_name)) + elif _edit == "category": + _category = user_input[3] + _rating = user_input[4] + subject_edit = subject.get_subject(subjects, _subject) 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], user_input[3], user_input[4])) - elif user_input[0] == "output": - subject_get = subject.get_subject(subjects, user_input[1]) + subject_edit.add_grade_category(_category, _rating) + elif _edit == "subject": + _main = user_input[3] + _oral = user_input[4] + subjects.append(subject.Subject(_subject, _main, _oral)) + elif input_or_output == "output": + _subject = user_input[1] + subject_get = subject.get_subject(subjects, _subject) user_IO.user_output(subject_get.return_average_subject) raise SystemError