From 95f76de75dfca753481873d439b2b710087b543e Mon Sep 17 00:00:00 2001 From: flovnes Date: Sat, 27 Apr 2024 23:59:48 +0300 Subject: [PATCH] reset --- gen.py | 27 +++++++++++++++++++++++++++ input.txt | 23 ++++++++++++++++++++--- src/methods.cs | 24 +----------------------- tests/tests.cs | 47 ++++++----------------------------------------- 4 files changed, 54 insertions(+), 67 deletions(-) create mode 100644 gen.py diff --git a/gen.py b/gen.py new file mode 100644 index 0000000..4faf935 --- /dev/null +++ b/gen.py @@ -0,0 +1,27 @@ +import random + +surnames = ['surname1', 'surname2', 'surname3', 'surname4'] +firstnames = ['firstname1', 'firstname2', 'firstname3', 'firstname4'] +patronymics = ['patronymic1', 'patronymic2', 'patronymic3', 'patronymic4'] +sexes = ['M', 'F'] +marks = [1, 2, 3, 4, 5, '-'] +scholarships = list(range(1234, 4322)) + +lines = [] +for _ in range(20): + surname = random.choice(surnames) + firstname = random.choice(firstnames) + patronymic = random.choice(patronymics) + sex = random.choice(sexes) + date_of_birth = f"{random.randint(1, 28):02d}.{random.randint(1, 12):02d}.{random.randint(1995, 2005)}" + mark1 = random.choice(marks) + mark2 = random.choice(marks) + mark3 = random.choice(marks) + scholarship = random.choice(scholarships) + + line = f"{surname} {firstname} {patronymic} {sex} {date_of_birth} {mark1} {mark2} {mark3} {scholarship}" + lines.append(line) + +with open('input.txt', 'w') as file: + for line in lines: + file.write(line + '\n') diff --git a/input.txt b/input.txt index 3d9b999..75cea48 100644 --- a/input.txt +++ b/input.txt @@ -1,3 +1,20 @@ -Прізвище1 Ім'я1 По-батькові1 F 02.02.2000 4 4 - 1234 -Прізвище2 Ім'я2 По-батькові2 F 02.02.2000 4 - 2 1234 -Прізвище3 Ім'я3 По-батькові3 F 03.03.2000 3 - - 2413 \ No newline at end of file +surname2 firstname3 patronymic3 F 06.12.1995 - 3 5 4756 +surname4 firstname2 patronymic3 F 10.09.1995 2 - 1 3291 +surname2 firstname4 patronymic4 F 07.05.2004 2 3 3 2103 +surname1 firstname1 patronymic2 F 05.05.1998 1 - - 2766 +surname3 firstname2 patronymic3 M 03.02.2001 - 3 1 2260 +surname1 firstname1 patronymic2 F 12.04.2002 2 3 - 4495 +surname4 firstname1 patronymic3 F 04.09.2005 3 2 4 4183 +surname3 firstname1 patronymic2 F 08.07.2004 5 5 2 4345 +surname2 firstname2 patronymic1 M 22.01.1999 2 1 5 3870 +surname1 firstname1 patronymic1 M 04.05.2005 4 3 4 3302 +surname2 firstname3 patronymic3 F 16.12.1995 1 3 5 2801 +surname3 firstname2 patronymic3 F 24.08.1999 4 5 3 4139 +surname4 firstname3 patronymic4 M 26.07.1998 2 3 4 2548 +surname1 firstname3 patronymic1 M 23.06.1998 1 4 - 1092 +surname1 firstname3 patronymic2 F 15.10.2000 5 3 3 1577 +surname2 firstname2 patronymic2 M 08.12.2004 3 5 2 4394 +surname4 firstname1 patronymic3 M 05.08.1998 2 - 2 1404 +surname3 firstname4 patronymic3 F 15.12.1998 1 3 4 1133 +surname3 firstname3 patronymic2 M 06.09.2000 2 3 3 1118 +surname4 firstname2 patronymic3 F 22.12.2003 3 4 3 2677 diff --git a/src/methods.cs b/src/methods.cs index 02be3ca..b2f8ab8 100644 --- a/src/methods.cs +++ b/src/methods.cs @@ -2,28 +2,6 @@ namespace struct_lab_student { public partial class Program { static void Var9(List students) { } static void Var10(List students) { } - static void Var24(List students) { - List averages = EvalAverages(students); - foreach (double n in averages) { Console.WriteLine(n); } - } - - public static List EvalAverages(List students) { - List averages = []; - foreach (var dude in students) - { - int[] marks = new int[3]; - int sum = 0; - foreach (char mark in dude.Marks) - { - for (int i = 0; i < 3; i++) - marks[i] = (mark == '-') ? 2 : mark - '0'; - } - for (int i = 0; i < 3; i++) - sum += marks[i]; - averages.Add(sum / 3.0); - } - - return averages; - } + static void Var24(List students) { } } } \ No newline at end of file diff --git a/tests/tests.cs b/tests/tests.cs index 5813e21..2d8be50 100644 --- a/tests/tests.cs +++ b/tests/tests.cs @@ -4,47 +4,12 @@ namespace student_tests { public partial class Tests { [Fact] - public static void Student_EvalAverages_ReturnDoubleList() { - try - { - Student a = new("Прізвище1 Ім'я1 По-батькові1 F 02.02.2000 4 4 - 1234"); - Student b = new("Прізвище2 Ім'я2 По-батькові2 F 02.02.2000 4 - 2 1234"); - Student c = new("Прізвище3 Ім'я3 По-батькові3 F 03.03.2000 3 - - 2413"); - List avgs = Program.EvalAverages([a,b,c]); - bool fail = false; - foreach (double avg in avgs) { - if (avg < 2.0) { - fail = true; - break; - } - } - Console.WriteLine(fail ? "Student_EvalAverages_ReturnDoubleList epic fail!!!" : "cool!"); - } - catch (Exception e) - { - Console.WriteLine($"\n\n uhoh somethin dun gone wrong! \n {e} \n\n"); - } + public static void Student_Constructor_ReturnStudentList() { + List students = []; + students.Add(new("Прізвище1 Ім'я1 По-батькові1 M 02.02.2000 3 4 5 1234")); + students.Add(new("surname FIRST_NAME 🔥 F 02.02.2000 4 - 2 1234")); + students.Add(new("1 2 3 4 5 - - - 6")); + Console.WriteLine(students.Count < 3 ? "this is a test, stupid" : "no way!"); } - [Fact] - public static void Student_EvalAverages_ReturnDoubleList() { - try - { - Student a = new("Прізвище1 Ім'я1 По-батькові1 F 02.02.2000 4 4 - 1234"); - Student b = new("Прізвище2 Ім'я2 По-батькові2 F 02.02.2000 4 - 2 1234"); - Student c = new("Прізвище3 Ім'я3 По-батькові3 F 03.03.2000 3 - - 2413"); - List avgs = Program.EvalAverages([a,b,c]); - bool fail = false; - foreach (double avg in avgs) { - if (avg < 2.0) { - fail = true; - break; - } - } - Console.WriteLine(fail ? "Student_EvalAverages_ReturnDoubleList epic fail!!!" : "cool!"); - } - catch (Exception e) - { - Console.WriteLine($"\n\n uhoh somethin dun gone wrong! \n {e} \n\n"); - } } \ No newline at end of file