Skip to content

Commit

Permalink
reset
Browse files Browse the repository at this point in the history
  • Loading branch information
flovnes committed Apr 27, 2024
1 parent a751540 commit 95f76de
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 67 deletions.
27 changes: 27 additions & 0 deletions gen.py
Original file line number Diff line number Diff line change
@@ -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')
23 changes: 20 additions & 3 deletions input.txt
Original file line number Diff line number Diff line change
@@ -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
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
24 changes: 1 addition & 23 deletions src/methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@ namespace struct_lab_student {
public partial class Program {
static void Var9(List<Student> students) { }
static void Var10(List<Student> students) { }
static void Var24(List<Student> students) {
List<double> averages = EvalAverages(students);
foreach (double n in averages) { Console.WriteLine(n); }
}

public static List<double> EvalAverages(List<Student> students) {
List<double> 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<Student> students) { }
}
}
47 changes: 6 additions & 41 deletions tests/tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> 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<Student> 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<double> 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");

}
}

0 comments on commit 95f76de

Please sign in to comment.