From e76432a073520b9f4288cc5d5a2a673935d2d34e Mon Sep 17 00:00:00 2001 From: "DESKTOP-R1476QT\\Emil" Date: Wed, 26 Aug 2020 09:46:33 +0200 Subject: [PATCH 1/9] Initial commit - Session02 --- .../Session02Exercise01.sln | 25 +++++++++++++++++++ .../Session02Exercise01/Program.cs | 12 +++++++++ .../Session02Exercise01.csproj | 8 ++++++ 3 files changed, 45 insertions(+) create mode 100644 Session02/Session02Exercise01/Session02Exercise01.sln create mode 100644 Session02/Session02Exercise01/Session02Exercise01/Program.cs create mode 100644 Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj diff --git a/Session02/Session02Exercise01/Session02Exercise01.sln b/Session02/Session02Exercise01/Session02Exercise01.sln new file mode 100644 index 0000000..28dd3a4 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{C7C5AC77-CCBC-40BE-B01E-A04231BF2435}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EAD30D92-EF25-4EBE-9F49-6117BC2B0E6F} + EndGlobalSection +EndGlobal diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs new file mode 100644 index 0000000..a37fc8d --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Session02Exercise01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj b/Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Exercise01/Session02Exercise01/Session02Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From 77374d50832f91bbba964d62fb804d37ffbe419a Mon Sep 17 00:00:00 2001 From: "DESKTOP-R1476QT\\Emil" Date: Wed, 26 Aug 2020 10:50:06 +0200 Subject: [PATCH 2/9] revert --- Session02/Session02Exercise01/Session02Exercise01/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs index a37fc8d..2e80d4e 100644 --- a/Session02/Session02Exercise01/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -7,6 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); + + var integer = 0; + + Console.WriteLine("Integer is " + integer.ToString()); } } } From 74d7b0da653ccfd10826c483e23a92022ab2a81e Mon Sep 17 00:00:00 2001 From: "DESKTOP-R1476QT\\Emil" Date: Wed, 26 Aug 2020 10:50:45 +0200 Subject: [PATCH 3/9] revert --- Session02/Session02Exercise01/Session02Exercise01/Program.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs index 2e80d4e..0bd8fae 100644 --- a/Session02/Session02Exercise01/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -8,9 +8,7 @@ static void Main(string[] args) { Console.WriteLine("Hello World!"); - var integer = 0; - Console.WriteLine("Integer is " + integer.ToString()); } } -} +} \ No newline at end of file From bf667dc5c5aea2384ba0a087bab28f76c60a0701 Mon Sep 17 00:00:00 2001 From: "DESKTOP-R1476QT\\Emil" Date: Wed, 26 Aug 2020 10:55:56 +0200 Subject: [PATCH 4/9] revert --- Session02/Session02Exercise01/Session02Exercise01/Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs index 0bd8fae..c4813d8 100644 --- a/Session02/Session02Exercise01/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -8,7 +8,10 @@ static void Main(string[] args) { Console.WriteLine("Hello World!"); + var integer = 0; + Console.WriteLine("Integer is " + integer.ToString()); } } + } } \ No newline at end of file From d8d6d05afb41b52579d2f3e7d7502979dd40acbd Mon Sep 17 00:00:00 2001 From: Emil Martinelle Date: Fri, 28 Aug 2020 09:16:11 +0200 Subject: [PATCH 5/9] Session03 - Exercises01-02 --- .../Session02Example01/Program.cs | 95 +++++++++++++++++++ .../Session02Example02/Program.cs | 29 ++++++ .../Session02Example02.csproj | 8 ++ .../Session02Example03/Program.cs | 35 +++++++ .../Session02Example03.csproj | 8 ++ .../Session02Exercise01.sln | 26 ++++- .../Session02Exercise01/Program.cs | 7 +- .../Session02Exerciese02/Program.cs | 24 +++++ .../Session02Exerciese02.csproj | 8 ++ .../Session03Exercise01.sln | 31 ++++++ .../Session03Exercise01/Program.cs | 40 ++++++++ .../Session03Exercise01.csproj | 8 ++ .../Session03Exercise02/Program.cs | 21 ++++ .../Session03Exercise02.csproj | 8 ++ 14 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 Session02/Session02Example01/Session02Example01/Program.cs create mode 100644 Session02/Session02Example02/Session02Example02/Program.cs create mode 100644 Session02/Session02Example02/Session02Example02/Session02Example02.csproj create mode 100644 Session02/Session02Example03/Session02Example03/Program.cs create mode 100644 Session02/Session02Example03/Session02Example03/Session02Example03.csproj create mode 100644 Session02/Session02Exercise02/Session02Exerciese02/Program.cs create mode 100644 Session02/Session02Exercise02/Session02Exerciese02/Session02Exerciese02.csproj create mode 100644 Session03/Session03Exercise01/Session03Exercise01.sln create mode 100644 Session03/Session03Exercise01/Session03Exercise01/Program.cs create mode 100644 Session03/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj create mode 100644 Session03/Session03Exercise01/Session03Exercise02/Program.cs create mode 100644 Session03/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj diff --git a/Session02/Session02Example01/Session02Example01/Program.cs b/Session02/Session02Example01/Session02Example01/Program.cs new file mode 100644 index 0000000..97ca4a9 --- /dev/null +++ b/Session02/Session02Example01/Session02Example01/Program.cs @@ -0,0 +1,95 @@ +using System; +using System.Xml.Schema; + +namespace Session02Example01 +{ + class Program + { + static void Main(string[] args) + { + // Binary operation + var additionResult = 1 + 2; + + Console.WriteLine("additionalResult " + additionResult.ToString()); + + var incrementResult = ++additionResult; + + Console.WriteLine("incrementResult " + incrementResult.ToString()); + + var trueValue = true; + + var falseValue = false; + + var andResult = trueValue & falseValue; // 0b0110 + var orResult = trueValue | falseValue; + var xorResult = trueValue ^ falseValue; + + Console.WriteLine("andResult " + andResult); + Console.WriteLine("orResult " + orResult); + Console.WriteLine("xorResult " + xorResult); + + var moduloResult = 7 % 5; + + Console.WriteLine("moduloResult " + moduloResult); + + var highInteger = 1000; + var IntegerDivisionResult = highInteger / 3; + + // Implicit värdekonvertering till double + var doubleDivisionResult = highInteger / 3.0; + + Console.WriteLine("integerDivisionResult " + IntegerDivisionResult); + Console.WriteLine("doubleDivisionResult " + doubleDivisionResult); + + var castIntDivisionResult = (int)(highInteger / 3.0); + + Console.WriteLine("castIntDivisionResults " + castIntDivisionResult); + + var conversionResult = Convert.ToInt32(doubleDivisionResult); + + Console.WriteLine("convertionResult " + conversionResult); + + var midpointDivisionResult = 10.0 / 3.0; + + Console.WriteLine("midpointDivisionResult " + midpointDivisionResult); + Console.WriteLine("castToInt " + ((int)midpointDivisionResult).ToString()); + + Console.WriteLine("ceiling " +Math.Ceiling(midpointDivisionResult)); + Console.WriteLine("floor " + Math.Floor(midpointDivisionResult)); + Console.WriteLine("round " + Math.Round(midpointDivisionResult)); + // Med decimaler + Console.WriteLine("round " + Math.Round(midpointDivisionResult,3)); + + + additionResult += 2; + additionResult -= 2; + additionResult /= 2; + additionResult *= 2; + + //^^ Smidigare sätt än det nedanför. Gör samma sak + + additionResult = additionResult + 2; + + var greaterResult = 5 > 3; + var lessThanResult = 5 < 3; + var greaterOrEqual = 5 >= 3; + var lessOrEqual = 5 <= 3; + + Console.WriteLine("greaterResult " + greaterResult); + Console.WriteLine("lessThanResult " + lessThanResult); + Console.WriteLine("greaterOrEqual " + greaterOrEqual); + Console.WriteLine("lessOrEqual " + lessOrEqual); + + var andOperationResult = true && false; + var orOperationalResult = false || true; + + Console.WriteLine("andOperationalResult " + andOperationResult); + Console.WriteLine("orOperationalResult " + orOperationalResult); + + + + Console.ReadKey(); + + } + } +} diff --git a/Session02/Session02Example02/Session02Example02/Program.cs b/Session02/Session02Example02/Session02Example02/Program.cs new file mode 100644 index 0000000..f2a6a2f --- /dev/null +++ b/Session02/Session02Example02/Session02Example02/Program.cs @@ -0,0 +1,29 @@ +using System; + +namespace Session02Example02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange Ålder: "); + + var input = Console.ReadLine(); + var integer = Convert.ToInt32(input); + + if (integer >= 18) + { + Console.WriteLine("Du får köpa tobaksprodukter"); + } + else + { + Console.WriteLine("Du får inte köpa tobaksprodukter"); + } + + if (integer >= 40) + { + Console.WriteLine("Du är även jättegammal"); + } + } + } +} diff --git a/Session02/Session02Example02/Session02Example02/Session02Example02.csproj b/Session02/Session02Example02/Session02Example02/Session02Example02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Example02/Session02Example02/Session02Example02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Session02Example03/Session02Example03/Program.cs b/Session02/Session02Example03/Session02Example03/Program.cs new file mode 100644 index 0000000..f6c2f9c --- /dev/null +++ b/Session02/Session02Example03/Session02Example03/Program.cs @@ -0,0 +1,35 @@ +using System; + +namespace Session02Example03 +{ + class Program + { + static void Main(string[] args) + { + var input = Console.ReadLine(); + var integer = Convert.ToInt32(input); + + string waterLabel = integer >= 27 ? "Går bra att bada" : "Går inte att bada"; + + /*/if(integer >27) + { + waterLabel = "Går bra att bada"; + } + else + { + waterLabel = "Går inte bra att bada"; + } + /*/ + + //Om det är dessa exakta värden inträffar + switch (integer) + { + case 1: waterLabel = "Går inte bra att bada alls"; break; + case 3-: waterLabel = "Det är 3 minusgrader"; break; + default: /*Här kan man göra något om inget träffar*/ break; + } + Console.WriteLine(waterLabel + " i havet"); + + } + } +} diff --git a/Session02/Session02Example03/Session02Example03/Session02Example03.csproj b/Session02/Session02Example03/Session02Example03/Session02Example03.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Example03/Session02Example03/Session02Example03.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Session02Exercise01/Session02Exercise01.sln b/Session02/Session02Exercise01/Session02Exercise01.sln index 28dd3a4..d75bcd4 100644 --- a/Session02/Session02Exercise01/Session02Exercise01.sln +++ b/Session02/Session02Exercise01/Session02Exercise01.sln @@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30413.136 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{C7C5AC77-CCBC-40BE-B01E-A04231BF2435}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{C7C5AC77-CCBC-40BE-B01E-A04231BF2435}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exerciese02", "..\Session02Exercise02\Session02Exerciese02\Session02Exerciese02.csproj", "{5D199AF6-E1AC-4316-ACD8-72C33D0F47E7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Example01", "..\Session02Example01\Session02Example01\Session02Example01.csproj", "{0BE5C649-99A1-443F-963B-A4AA9C527A24}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Example02", "..\Session02Example02\Session02Example02\Session02Example02.csproj", "{B9F20334-BBF4-425D-A266-EED6BD88E17E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Example03", "..\Session02Example03\Session02Example03\Session02Example03.csproj", "{2FE6A791-64C2-4570-AD03-BF45214E8853}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +23,22 @@ Global {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Debug|Any CPU.Build.0 = Debug|Any CPU {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7C5AC77-CCBC-40BE-B01E-A04231BF2435}.Release|Any CPU.Build.0 = Release|Any CPU + {5D199AF6-E1AC-4316-ACD8-72C33D0F47E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D199AF6-E1AC-4316-ACD8-72C33D0F47E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D199AF6-E1AC-4316-ACD8-72C33D0F47E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D199AF6-E1AC-4316-ACD8-72C33D0F47E7}.Release|Any CPU.Build.0 = Release|Any CPU + {0BE5C649-99A1-443F-963B-A4AA9C527A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0BE5C649-99A1-443F-963B-A4AA9C527A24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0BE5C649-99A1-443F-963B-A4AA9C527A24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0BE5C649-99A1-443F-963B-A4AA9C527A24}.Release|Any CPU.Build.0 = Release|Any CPU + {B9F20334-BBF4-425D-A266-EED6BD88E17E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9F20334-BBF4-425D-A266-EED6BD88E17E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9F20334-BBF4-425D-A266-EED6BD88E17E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9F20334-BBF4-425D-A266-EED6BD88E17E}.Release|Any CPU.Build.0 = Release|Any CPU + {2FE6A791-64C2-4570-AD03-BF45214E8853}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FE6A791-64C2-4570-AD03-BF45214E8853}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FE6A791-64C2-4570-AD03-BF45214E8853}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FE6A791-64C2-4570-AD03-BF45214E8853}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Session02/Session02Exercise01/Session02Exercise01/Program.cs b/Session02/Session02Exercise01/Session02Exercise01/Program.cs index c4813d8..55be8c4 100644 --- a/Session02/Session02Exercise01/Session02Exercise01/Program.cs +++ b/Session02/Session02Exercise01/Session02Exercise01/Program.cs @@ -11,7 +11,10 @@ static void Main(string[] args) var integer = 0; Console.WriteLine("Integer is " + integer.ToString()); + string stringValue = "MyStringValue"; + + Console.WriteLine("The value of stringValue is:" + stringValue); + } } - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/Session02/Session02Exercise02/Session02Exerciese02/Program.cs b/Session02/Session02Exercise02/Session02Exerciese02/Program.cs new file mode 100644 index 0000000..6613483 --- /dev/null +++ b/Session02/Session02Exercise02/Session02Exerciese02/Program.cs @@ -0,0 +1,24 @@ +using System; + +namespace Session02Exerciese02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Do you want to enter your name? (y/n)"); + var key = Console.ReadKey(); + + if (key.KeyChar == 'n') + return; + + + + Console.WriteLine("Enter your name:"); + var name = Console.ReadLine(); + + Console.WriteLine("Hello, " + name); + Console.ReadKey(); + } + } +} diff --git a/Session02/Session02Exercise02/Session02Exerciese02/Session02Exerciese02.csproj b/Session02/Session02Exercise02/Session02Exerciese02/Session02Exerciese02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02Exercise02/Session02Exerciese02/Session02Exerciese02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session03/Session03Exercise01/Session03Exercise01.sln b/Session03/Session03Exercise01/Session03Exercise01.sln new file mode 100644 index 0000000..99d07f7 --- /dev/null +++ b/Session03/Session03Exercise01/Session03Exercise01.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise01", "Session03Exercise01\Session03Exercise01.csproj", "{1DA37EB2-8B33-4F46-9531-0BF485D85D43}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{4EC32C31-2B0E-43AF-AF81-0AE8350D391A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Release|Any CPU.Build.0 = Release|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C3302251-CC54-46F8-8F3E-6513ADE2B657} + EndGlobalSection +EndGlobal diff --git a/Session03/Session03Exercise01/Session03Exercise01/Program.cs b/Session03/Session03Exercise01/Session03Exercise01/Program.cs new file mode 100644 index 0000000..c405287 --- /dev/null +++ b/Session03/Session03Exercise01/Session03Exercise01/Program.cs @@ -0,0 +1,40 @@ +using System; + +namespace Session03Exercise01 +{ + class Program + { + static void Main(string[] args) + { + int[] integerValues = new [] { 1, 2, 3 }; + var integerValueName = nameof(integerValues); + + for (var i = 0; i < integers.Length; i++) + { + var name = nameof(integers); + var value = integers[i]; + + Console.WriteLine($"Index {i} i arrayen {nameof(integers)} har värdet: {integers[i]}"); + } + var doWhileIndex = 0; + + do + { + var value = integerValues[doWhileIndex]; + + Console.WriteLine($"Index{doWhileIndex} i arrayen {integerValueName} har värdet: {value}"); + doWhileIndex++; + } + while (doWhileIndex < integerValues.Length); + + var whileIndex = 0; + + while (whileIndex++ < integersValues < whileIndex) + + Console.WriteLine($"While Index {whileIndex} i arrayen {integerValueName} har värdet: {value}"); + + whileIndex++; + + } + } +} diff --git a/Session03/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj b/Session03/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session03/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session03/Session03Exercise01/Session03Exercise02/Program.cs b/Session03/Session03Exercise01/Session03Exercise02/Program.cs new file mode 100644 index 0000000..3c42c62 --- /dev/null +++ b/Session03/Session03Exercise01/Session03Exercise02/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Session03Exercise02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); + + var input = Console.ReadLine(); + + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + + foreach (var number in inputArray) + { + Console.WriteLine("Värdet är " + number); + } + } + } +} diff --git a/Session03/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj b/Session03/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session03/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From 185cdc154e0fe74cfd8c23ffb6803b7b8b011f93 Mon Sep 17 00:00:00 2001 From: Emil Martinelle Date: Fri, 28 Aug 2020 09:32:33 +0200 Subject: [PATCH 6/9] exercise02 --- .../Session03Exercise01.sln | 31 ++++++++++++++ .../Session03Exercise01/Program.cs | 40 +++++++++++++++++++ .../Session03Exercise01.csproj | 8 ++++ .../Session03Exercise02/Program.cs | 21 ++++++++++ .../Session03Exercise02.csproj | 8 ++++ 5 files changed, 108 insertions(+) create mode 100644 Ny mapp/Session03Exercise01/Session03Exercise01.sln create mode 100644 Ny mapp/Session03Exercise01/Session03Exercise01/Program.cs create mode 100644 Ny mapp/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj create mode 100644 Ny mapp/Session03Exercise01/Session03Exercise02/Program.cs create mode 100644 Ny mapp/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj diff --git a/Ny mapp/Session03Exercise01/Session03Exercise01.sln b/Ny mapp/Session03Exercise01/Session03Exercise01.sln new file mode 100644 index 0000000..99d07f7 --- /dev/null +++ b/Ny mapp/Session03Exercise01/Session03Exercise01.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise01", "Session03Exercise01\Session03Exercise01.csproj", "{1DA37EB2-8B33-4F46-9531-0BF485D85D43}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{4EC32C31-2B0E-43AF-AF81-0AE8350D391A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DA37EB2-8B33-4F46-9531-0BF485D85D43}.Release|Any CPU.Build.0 = Release|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C3302251-CC54-46F8-8F3E-6513ADE2B657} + EndGlobalSection +EndGlobal diff --git a/Ny mapp/Session03Exercise01/Session03Exercise01/Program.cs b/Ny mapp/Session03Exercise01/Session03Exercise01/Program.cs new file mode 100644 index 0000000..c405287 --- /dev/null +++ b/Ny mapp/Session03Exercise01/Session03Exercise01/Program.cs @@ -0,0 +1,40 @@ +using System; + +namespace Session03Exercise01 +{ + class Program + { + static void Main(string[] args) + { + int[] integerValues = new [] { 1, 2, 3 }; + var integerValueName = nameof(integerValues); + + for (var i = 0; i < integers.Length; i++) + { + var name = nameof(integers); + var value = integers[i]; + + Console.WriteLine($"Index {i} i arrayen {nameof(integers)} har värdet: {integers[i]}"); + } + var doWhileIndex = 0; + + do + { + var value = integerValues[doWhileIndex]; + + Console.WriteLine($"Index{doWhileIndex} i arrayen {integerValueName} har värdet: {value}"); + doWhileIndex++; + } + while (doWhileIndex < integerValues.Length); + + var whileIndex = 0; + + while (whileIndex++ < integersValues < whileIndex) + + Console.WriteLine($"While Index {whileIndex} i arrayen {integerValueName} har värdet: {value}"); + + whileIndex++; + + } + } +} diff --git a/Ny mapp/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj b/Ny mapp/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Ny mapp/Session03Exercise01/Session03Exercise01/Session03Exercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Ny mapp/Session03Exercise01/Session03Exercise02/Program.cs b/Ny mapp/Session03Exercise01/Session03Exercise02/Program.cs new file mode 100644 index 0000000..3c42c62 --- /dev/null +++ b/Ny mapp/Session03Exercise01/Session03Exercise02/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Session03Exercise02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); + + var input = Console.ReadLine(); + + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + + foreach (var number in inputArray) + { + Console.WriteLine("Värdet är " + number); + } + } + } +} diff --git a/Ny mapp/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj b/Ny mapp/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Ny mapp/Session03Exercise01/Session03Exercise02/Session03Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From c7d891bf176d5b868750d0fab349059a2ed0414e Mon Sep 17 00:00:00 2001 From: Emil Martinelle Date: Fri, 28 Aug 2020 09:36:29 +0200 Subject: [PATCH 7/9] numbers --- .../Session03Exercise01.sln | 10 ++++++-- .../Session03Numbers/Program.cs | 25 +++++++++++++++++++ .../Session03Numbers/Session03Numbers.csproj | 8 ++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 Session03/Session03Exercise01/Session03Numbers/Program.cs create mode 100644 Session03/Session03Exercise01/Session03Numbers/Session03Numbers.csproj diff --git a/Session03/Session03Exercise01/Session03Exercise01.sln b/Session03/Session03Exercise01/Session03Exercise01.sln index 99d07f7..298d70a 100644 --- a/Session03/Session03Exercise01/Session03Exercise01.sln +++ b/Session03/Session03Exercise01/Session03Exercise01.sln @@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30413.136 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise01", "Session03Exercise01\Session03Exercise01.csproj", "{1DA37EB2-8B33-4F46-9531-0BF485D85D43}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session03Exercise01", "Session03Exercise01\Session03Exercise01.csproj", "{1DA37EB2-8B33-4F46-9531-0BF485D85D43}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{4EC32C31-2B0E-43AF-AF81-0AE8350D391A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{4EC32C31-2B0E-43AF-AF81-0AE8350D391A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Numbers", "Session03Numbers\Session03Numbers.csproj", "{1C6E64D2-5B10-4FAB-BF60-9EF1887357B9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +23,10 @@ Global {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EC32C31-2B0E-43AF-AF81-0AE8350D391A}.Release|Any CPU.Build.0 = Release|Any CPU + {1C6E64D2-5B10-4FAB-BF60-9EF1887357B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C6E64D2-5B10-4FAB-BF60-9EF1887357B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C6E64D2-5B10-4FAB-BF60-9EF1887357B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C6E64D2-5B10-4FAB-BF60-9EF1887357B9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Session03/Session03Exercise01/Session03Numbers/Program.cs b/Session03/Session03Exercise01/Session03Numbers/Program.cs new file mode 100644 index 0000000..36fa4fc --- /dev/null +++ b/Session03/Session03Exercise01/Session03Numbers/Program.cs @@ -0,0 +1,25 @@ +using System; + +namespace Session03Numbers +{ + using System; + + namespace Session03Exercise02 + { + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); + + var input = Console.ReadLine(); + + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + + foreach (var number in inputArray) + { + Console.WriteLine("Värdet är " + number); + } + } + } + } diff --git a/Session03/Session03Exercise01/Session03Numbers/Session03Numbers.csproj b/Session03/Session03Exercise01/Session03Numbers/Session03Numbers.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session03/Session03Exercise01/Session03Numbers/Session03Numbers.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From 9201e5689b2fc9b69510ee604e4624f865e740d1 Mon Sep 17 00:00:00 2001 From: Emil Martinelle Date: Fri, 28 Aug 2020 11:30:47 +0200 Subject: [PATCH 8/9] numbers --- NumbersTest/NumbersTest/NumbersTest.sln | 25 +++++++++ .../NumbersTest/NumbersTest.csproj | 8 +++ .../NumbersTest/NumbersTest/Program.cs | 51 +++++++++++++++++++ .../Session03Numbers/Program.cs | 30 +++++++++++ 4 files changed, 114 insertions(+) create mode 100644 NumbersTest/NumbersTest/NumbersTest.sln create mode 100644 NumbersTest/NumbersTest/NumbersTest/NumbersTest.csproj create mode 100644 NumbersTest/NumbersTest/NumbersTest/Program.cs diff --git a/NumbersTest/NumbersTest/NumbersTest.sln b/NumbersTest/NumbersTest/NumbersTest.sln new file mode 100644 index 0000000..81cc888 --- /dev/null +++ b/NumbersTest/NumbersTest/NumbersTest.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NumbersTest", "NumbersTest\NumbersTest.csproj", "{408EA78E-1721-4604-85CC-08B454FA2E3B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {408EA78E-1721-4604-85CC-08B454FA2E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {408EA78E-1721-4604-85CC-08B454FA2E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {408EA78E-1721-4604-85CC-08B454FA2E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {408EA78E-1721-4604-85CC-08B454FA2E3B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9E1D9868-8CBD-46CF-854B-B2788774905B} + EndGlobalSection +EndGlobal diff --git a/NumbersTest/NumbersTest/NumbersTest/NumbersTest.csproj b/NumbersTest/NumbersTest/NumbersTest/NumbersTest.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/NumbersTest/NumbersTest/NumbersTest/NumbersTest.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/NumbersTest/NumbersTest/NumbersTest/Program.cs b/NumbersTest/NumbersTest/NumbersTest/Program.cs new file mode 100644 index 0000000..65deb39 --- /dev/null +++ b/NumbersTest/NumbersTest/NumbersTest/Program.cs @@ -0,0 +1,51 @@ +namespace Session03Numbers +{ + using System; + + namespace Session03Exercise02 + { + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); + + var input = Console.ReadLine(); + + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + double[] numberArray = new double[inputArray.Length]; + + for (int i = 0; i < inputArray.Length; i++) + { + try + { + numberArray[i] = Convert.ToDouble(inputArray[i]); + } + + catch (Exception) + { + numberArray[i] = 0; + } + + finally /*/Körs alltid ovasett vad som händer med koden + * Måste vara i en loop /*/ + { + + } + /*/throw new Exception("Provocerat fel") Är ett egenskapat fel/*/ + + foreach (var number in numberArray) + { + Console.WriteLine("Värde: " + number.ToString()); + } + + + + } + } + + } + } +} + + diff --git a/Session03/Session03Exercise01/Session03Numbers/Program.cs b/Session03/Session03Exercise01/Session03Numbers/Program.cs index 36fa4fc..940dd68 100644 --- a/Session03/Session03Exercise01/Session03Numbers/Program.cs +++ b/Session03/Session03Exercise01/Session03Numbers/Program.cs @@ -16,10 +16,40 @@ static void Main(string[] args) var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + foreach (var number in inputArray) { Console.WriteLine("Värdet är " + number); } + using System; + +namespace Session03Numbers +{ + using System; + + namespace Session03Exercise02 + { + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffror, separat med kommatecken"); + + var input = Console.ReadLine(); + + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + + foreach (var number in inputArray) + { + Console.WriteLine("Värdet är " + number); + } + int lowestValue = (inputArray + 5); + + Console.WriteLine("Lägsta värdet är: " + lowestValue); + } + } + } + } } } From 26ae571fea741ac0473c8a03ee46026134858caf Mon Sep 17 00:00:00 2001 From: Emil Martinelle Date: Fri, 28 Aug 2020 13:08:30 +0200 Subject: [PATCH 9/9] Number app progress --- .../NumbersTest/NumbersTest/Program.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/NumbersTest/NumbersTest/NumbersTest/Program.cs b/NumbersTest/NumbersTest/NumbersTest/Program.cs index 65deb39..13161c9 100644 --- a/NumbersTest/NumbersTest/NumbersTest/Program.cs +++ b/NumbersTest/NumbersTest/NumbersTest/Program.cs @@ -1,6 +1,7 @@ namespace Session03Numbers { using System; + using System.Globalization; namespace Session03Exercise02 { @@ -17,6 +18,8 @@ static void Main(string[] args) for (int i = 0; i < inputArray.Length; i++) { + NumberStyles numberStyles=NumberStyles.Integer + try { numberArray[i] = Convert.ToDouble(inputArray[i]); @@ -27,8 +30,8 @@ static void Main(string[] args) numberArray[i] = 0; } - finally /*/Körs alltid ovasett vad som händer med koden - * Måste vara i en loop /*/ + /*/ finally Körs alltid ovasett vad som händer med koden + * Måste vara i en loop /*/ { } @@ -38,6 +41,23 @@ static void Main(string[] args) { Console.WriteLine("Värde: " + number.ToString()); } + static double GetDoubleValue(string input) + { + try + { + var result = int.Parse(input); + + return result; + } + catch (FormatException ex) when (ex.Message.Contains("Input string")) + { + return double.MinValue; + } + catch (Exception ex) + { + return 0; + } + }