From de9d18606d124b986ff28ed69e131632f52bf709 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 10:57:26 +0000 Subject: [PATCH 1/8] Setting up GitHub Classroom Feedback From c9952a62366de8cdaf1d02b82c5e66faba04f099 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 10:57:28 +0000 Subject: [PATCH 2/8] add deadline --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8743ae6..c934430 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/EBr0CZ_K) [![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/wgWXpqsn) # Методичні вказівки до виконання лабораторної роботи ## Тема: Масиви об’єктів From 000e7fe22631a968879fa7d042c98cd4e84296f4 Mon Sep 17 00:00:00 2001 From: TheMightyRoman Date: Thu, 9 Oct 2025 14:31:30 +0300 Subject: [PATCH 3/8] my comment --- Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index bea9748..9f70989 100644 --- a/Program.cs +++ b/Program.cs @@ -18,7 +18,7 @@ class Program static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("Hello World!. this is my lab"); } } } From 6693995dad195c793f33d575c27ac3aa447315f4 Mon Sep 17 00:00:00 2001 From: TheMightyRoman Date: Thu, 9 Oct 2025 14:34:17 +0300 Subject: [PATCH 4/8] lab3 --- Program.cs | 82 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/Program.cs b/Program.cs index 9f70989..b0ec511 100644 --- a/Program.cs +++ b/Program.cs @@ -1,24 +1,74 @@ using System; +using System.Linq; -namespace LabWork +class Abonent { - // Даний проект є шаблоном для виконання лабораторних робіт - // з курсу "Об'єктно-орієнтоване програмування та патерни проектування" - // Необхідно змінювати і дописувати код лише в цьому проекті - // Відео-інструкції щодо роботи з github можна переглянути - // за посиланням https://www.youtube.com/@ViktorZhukovskyy/videos - - class Result - { - // TODO: do it ! + public string Name { get; set; } + public string PhoneNumber { get; set; } + + // Конструктор + public Abonent(string name, string phoneNumber) + { + Name = name; + PhoneNumber = phoneNumber; + Console.WriteLine($"[Constructor] Абонент {Name} створений."); + } + + // Деструктор (Finalizer) + ~Abonent() + { + Console.WriteLine($"[Destructor] Абонент {Name} знищений."); } - - class Program + + // Метод для обчислення суми цифр номера телефону + public int GetPhoneDigitsSum() + { + return PhoneNumber + .Where(char.IsDigit) + .Select(digit => int.Parse(digit.ToString())) + .Sum(); + } +} + +class Program +{ + static void Main() { - static void Main(string[] args) + // Створення масиву абонентів + Abonent[] abonents = new Abonent[] { - - Console.WriteLine("Hello World!. this is my lab"); + new Abonent("Іван", "0671234567"), + new Abonent("Марія", "0509876543"), + new Abonent("Петро", "0932223333"), + new Abonent("Оксана", "0681112222") + }; + + // Знаходження абонента з найбільшою сумою цифр телефону + Abonent maxAbonent = abonents[0]; + int maxSum = maxAbonent.GetPhoneDigitsSum(); + + foreach (var ab in abonents) + { + int sum = ab.GetPhoneDigitsSum(); + Console.WriteLine($"Абонент: {ab.Name}, Номер: {ab.PhoneNumber}, Сума цифр: {sum}"); + + if (sum > maxSum) + { + maxSum = sum; + maxAbonent = ab; + } } + + Console.WriteLine($"\nАбонент з найбільшою сумою цифр номера телефону: {maxAbonent.Name}, Сума: {maxSum}"); + + // Демонстрація Garbage Collection + Console.WriteLine("\nОчищення посилань та виклик GC.Collect():"); + abonents = null; + + // Викликаємо збирач сміття + GC.Collect(); + GC.WaitForPendingFinalizers(); + + Console.WriteLine("Завершення програми..."); } -} +} \ No newline at end of file From 31ee9321f28935680e8afe60bb8e8717b39ac8fc Mon Sep 17 00:00:00 2001 From: Viktor Zhukovskyy Date: Thu, 9 Oct 2025 14:54:52 +0300 Subject: [PATCH 5/8] Update PR workflow to include additional event types --- .github/workflows/review.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 119d2a6..bc7a58e 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -2,7 +2,7 @@ name: PR Agent for NUWM on: pull_request: - types: [ opened, reopened ] + types: [ opened, reopened, synchronize, edited ] jobs: pr_agent_job: @@ -12,13 +12,13 @@ jobs: - name: pr-agent-nuwm uses: EzGrade/Pr-Agent-NUWM@main env: - APP_ID: ${{ secrets.APP_ID }} + GIT_APP_ID: ${{ secrets.GIT_APP_ID }} + GIT_PRIVATE_KEY: ${{ secrets.GIT_PRIVATE_KEY }} + GIT_INSTALLATION_ID: ${{ secrets.GIT_INSTALLATION_ID }} + GIT_REPOSITORY: ${{ github.repository }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REPOSITORY: ${{ github.repository }} - PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }} - INSTALLATION_ID: ${{ secrets.INSTALLATION_ID }} GOOGLE_CREDENTIALS_CONTENT: ${{ secrets.GOOGLE_CREDENTIALS_CONTENT }} - SPREADSHEET_URL: ${{ secrets.SPREADSHEET_URL }} - SHEETS_NAMING: ${{ secrets.SHEETS_NAMING }} + GOOGLE_SPREADSHEET_URL: ${{ secrets.GOOGLE_SPREADSHEET_URL }} + GOOGLE_SHEETS_NAMING: ${{ secrets.GOOGLE_SHEETS_NAMING }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1a51c4c49b89df5a9e519afedc9bb263e3bc6f3f Mon Sep 17 00:00:00 2001 From: Viktor Zhukovskyy Date: Thu, 9 Oct 2025 15:06:20 +0300 Subject: [PATCH 6/8] Add comment to Abonent constructor Added a comment to the constructor of the Abonent class. --- Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Program.cs b/Program.cs index b0ec511..1399f10 100644 --- a/Program.cs +++ b/Program.cs @@ -5,8 +5,8 @@ class Abonent { public string Name { get; set; } public string PhoneNumber { get; set; } - - // Конструктор + + // Конструктор 111 public Abonent(string name, string phoneNumber) { Name = name; @@ -71,4 +71,4 @@ static void Main() Console.WriteLine("Завершення програми..."); } -} \ No newline at end of file +} From c0dff0619ee15252534ec7663316266af5cf1d5f Mon Sep 17 00:00:00 2001 From: TheMightyRoman Date: Thu, 9 Oct 2025 15:15:48 +0300 Subject: [PATCH 7/8] lab3 --- Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index b0ec511..560a3f7 100644 --- a/Program.cs +++ b/Program.cs @@ -67,7 +67,7 @@ static void Main() // Викликаємо збирач сміття GC.Collect(); - GC.WaitForPendingFinalizers(); + GC.WaitForPendingFinalizers(); //test comment 15:15 Console.WriteLine("Завершення програми..."); } From 8e8ff9d21de46f4c90cfebb823a2fb9e778d8033 Mon Sep 17 00:00:00 2001 From: TheMightyRoman Date: Thu, 9 Oct 2025 15:25:12 +0300 Subject: [PATCH 8/8] lab3 edited --- Program.cs | 126 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 52 deletions(-) diff --git a/Program.cs b/Program.cs index be16758..919c932 100644 --- a/Program.cs +++ b/Program.cs @@ -1,74 +1,96 @@ using System; using System.Linq; -class Abonent +namespace PhoneDirectory { - public string Name { get; set; } - public string PhoneNumber { get; set; } - - // Конструктор 111 - public Abonent(string name, string phoneNumber) + public class Abonent { - Name = name; - PhoneNumber = phoneNumber; - Console.WriteLine($"[Constructor] Абонент {Name} створений."); - } + public string Name { get; } + public string PhoneNumber { get; } - // Деструктор (Finalizer) - ~Abonent() - { - Console.WriteLine($"[Destructor] Абонент {Name} знищений."); - } + public Abonent(string name, string phoneNumber) + { + if (string.IsNullOrWhiteSpace(name)) + throw new ArgumentException("Name cannot be null or empty.", nameof(name)); + if (string.IsNullOrWhiteSpace(phoneNumber)) + throw new ArgumentException("PhoneNumber cannot be null or empty.", nameof(phoneNumber)); - // Метод для обчислення суми цифр номера телефону - public int GetPhoneDigitsSum() - { - return PhoneNumber - .Where(char.IsDigit) - .Select(digit => int.Parse(digit.ToString())) - .Sum(); + Name = name; + PhoneNumber = phoneNumber; + } + + // Метод для обчислення суми цифр номера телефону + public int CalculatePhoneNumberDigitsSum() + { + if (string.IsNullOrEmpty(PhoneNumber)) + return 0; + + int sum = 0; + foreach (char c in PhoneNumber) + { + if (char.IsDigit(c)) + sum += c - '0'; // арифметичне перетворення символа в число + } + return sum; + } } -} -class Program -{ - static void Main() + internal class Program { - // Створення масиву абонентів - Abonent[] abonents = new Abonent[] + static void Main() { - new Abonent("Іван", "0671234567"), - new Abonent("Марія", "0509876543"), - new Abonent("Петро", "0932223333"), - new Abonent("Оксана", "0681112222") - }; + // Замість жорстко закодованого масиву можна ввести розмір масиву + Console.Write("Введіть кількість абонентів: "); + if (!int.TryParse(Console.ReadLine(), out int n) || n <= 0) + { + Console.WriteLine("Некоректна кількість."); + return; + } - // Знаходження абонента з найбільшою сумою цифр телефону - Abonent maxAbonent = abonents[0]; - int maxSum = maxAbonent.GetPhoneDigitsSum(); + Abonent[] abonents = new Abonent[n]; - foreach (var ab in abonents) - { - int sum = ab.GetPhoneDigitsSum(); - Console.WriteLine($"Абонент: {ab.Name}, Номер: {ab.PhoneNumber}, Сума цифр: {sum}"); + for (int i = 0; i < n; i++) + { + Console.Write($"Введіть ім'я абонента #{i + 1}: "); + string name = Console.ReadLine(); + + Console.Write($"Введіть номер телефону абонента #{i + 1}: "); + string phone = Console.ReadLine(); - if (sum > maxSum) + try + { + abonents[i] = new Abonent(name, phone); + } + catch (ArgumentException ex) + { + Console.WriteLine($"Помилка при створенні абонента: {ex.Message}"); + i--; // повторити введення для цього індексу + } + } + + if (abonents.Length == 0) { - maxSum = sum; - maxAbonent = ab; + Console.WriteLine("Масив абонентів пустий."); + return; } - } - Console.WriteLine($"\nАбонент з найбільшою сумою цифр номера телефону: {maxAbonent.Name}, Сума: {maxSum}"); + Abonent maxAbonent = abonents[0]; + int maxSum = maxAbonent.CalculatePhoneNumberDigitsSum(); - // Демонстрація Garbage Collection - Console.WriteLine("\nОчищення посилань та виклик GC.Collect():"); - abonents = null; + foreach (var ab in abonents) + { + int sum = ab.CalculatePhoneNumberDigitsSum(); + Console.WriteLine($"Абонент: {ab.Name}, Номер: {ab.PhoneNumber}, Сума цифр: {sum}"); - // Викликаємо збирач сміття - GC.Collect(); - GC.WaitForPendingFinalizers(); //test comment 15:15 + if (sum > maxSum) + { + maxSum = sum; + maxAbonent = ab; + } + } - Console.WriteLine("Завершення програми..."); + Console.WriteLine($"\nАбонент з найбільшою сумою цифр номера телефону: {maxAbonent.Name}, Сума: {maxSum}"); + Console.WriteLine("Завершення програми..."); + } } }