From 1bdaefa23cb855b6acbae8e43e63361aebb5667e Mon Sep 17 00:00:00 2001 From: Vegard Stigen Date: Wed, 6 Aug 2025 15:50:46 +0200 Subject: [PATCH] finished, all tests pass --- csharp-fundamentals-loops.Main/Core.cs | 36 +++++++++++++++++++---- csharp-fundamentals-loops.Main/Program.cs | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/csharp-fundamentals-loops.Main/Core.cs b/csharp-fundamentals-loops.Main/Core.cs index 9194643..bef1f37 100644 --- a/csharp-fundamentals-loops.Main/Core.cs +++ b/csharp-fundamentals-loops.Main/Core.cs @@ -20,32 +20,58 @@ public class Core public void stepOne() { // TODO: 1. Write a for loop that adds the numbers 0 to 3 to the numsZeroToThree array - throw new NotImplementedException(); + + for (int i = 0; i < 4; i++) + { + numsZeroToThree[i] = i; + } } public void stepTwo() { // TODO: 2. Write a for loop that adds the numbers 5 to 10 to the numsFiveToTen array - throw new NotImplementedException(); + for (int i = 5; i < 11; i++) + { + numsFiveToTen[i-5] = i; + } } public void stepThree() { // TODO: 3. Write a for loop that adds the numbers 3 to 0 (in that order) to the countdown array - throw new NotImplementedException(); + for (int i = 0; i < countdown.Length - 1; i++) + { + countdown[i] = countdown.Length - 1 - i; + } } + public bool stepFour(int num) { // TODO: 6. Write a for loop that checks if num is in the favouriteNumbers array - throw new NotImplementedException(); + for (int i = 0; i < favouriteNumbers.Length; i++) + { + if (num == favouriteNumbers[i]) + { + return true; + } + + } + return false; } public bool stepFive(string hobby) { // TODO 5. Write a for loop that checks if the hobby String is in the myHobbies array - throw new NotImplementedException(); + for (int i = 0; i < myHobbies.Length; i++) + { + if (hobby == myHobbies[i]) + { + return true; + } + } + return false; } } diff --git a/csharp-fundamentals-loops.Main/Program.cs b/csharp-fundamentals-loops.Main/Program.cs index 3751555..a1a5244 100644 --- a/csharp-fundamentals-loops.Main/Program.cs +++ b/csharp-fundamentals-loops.Main/Program.cs @@ -1,2 +1,2 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +Console.WriteLine("hello world");