Skip to content

Commit

Permalink
Merge branch 'main' into anton
Browse files Browse the repository at this point in the history
  • Loading branch information
flovnes authored Apr 29, 2024
2 parents 4dafc61 + 9442ff6 commit 5ec68b5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
36 changes: 21 additions & 15 deletions src/main.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Text;

namespace struct_lab_student {
public partial class Program {
static List<Student> ReadData(string fileName) {
namespace struct_lab_student
{
public partial class Program
{
static List<Student> ReadData(string fileName)
{
List<Student> students = [];
try {
try
{
StreamReader reader = new(fileName);
string? line;
while ((line = reader.ReadLine()) != null)
Expand All @@ -14,13 +16,17 @@ static List<Student> ReadData(string fileName) {
return students;
}

static void RunMenu(List<Student> students) {
static void RunMenu(List<Student> students)
{
int match;
do {
do
{
Console.Write("\n<- Вихід [0]\nВиконати варіант 9 студента Попов Антон [1]\nВиконати варіант 10 студента Дмитро Киба [2]\nВиконати варіант 24 студента Волощук Влад [3]\nНомер > ");
string? s = Console.ReadLine();
if (int.TryParse(s, out match)) {
switch (match) {
if (int.TryParse(s, out match))
{
switch (match)
{
case 1:
Var9(students);
break;
Expand All @@ -39,12 +45,12 @@ static void RunMenu(List<Student> students) {
}
} while (match != 0);
}


static void Main() {
Console.OutputEncoding = UTF8Encoding.UTF8;
static void Main()
{
Console.OutputEncoding = UTF8Encoding.UTF8;

Check failure on line 51 in src/main.cs

View workflow job for this annotation

GitHub Actions / build

The name 'UTF8Encoding' does not exist in the current context

Check failure on line 51 in src/main.cs

View workflow job for this annotation

GitHub Actions / build

The name 'UTF8Encoding' does not exist in the current context
List<Student> students = ReadData("../input.txt");
RunMenu(students);
}
}
}
}
21 changes: 14 additions & 7 deletions src/student.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace struct_lab_student {
public struct Student {
namespace struct_lab_student
{
public struct Student
{
public string surName;
public string firstName;
public string patronymic;
Expand All @@ -9,20 +11,25 @@ public struct Student {
public int scholarship;

// debug
public override readonly string ToString() {
public override readonly string ToString()
{
return surName + " " + firstName + " " + patronymic + " " + dateOfBirth;
}
public Student(string line) {
public Student(string line)
{
string[] fields = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
surName = fields[0];
firstName = fields[1];
patronymic = fields[2];
sex = char.Parse(fields[3]);
dateOfBirth = fields[4];
Marks = [
char.Parse(fields[5]),
char.Parse(fields[6]),
char.Parse(fields[7])
//math
char.Parse(fields[5]),
//physics
char.Parse(fields[6]),
// computer science
char.Parse(fields[7])
];
scholarship = int.Parse(fields[8]);
}
Expand Down

0 comments on commit 5ec68b5

Please sign in to comment.