From 12a5c5181583e7eb1cbad6ebc6593fd51f2be707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Wed, 26 Aug 2020 09:46:28 +0200 Subject: [PATCH 1/9] Inital commit Session02 --- Session02/Session02/Session02.sln | 25 +++++++++++++++++++ .../Session02/Session02Excercise01/Program.cs | 12 +++++++++ .../Session02Excercise01.csproj | 8 ++++++ 3 files changed, 45 insertions(+) create mode 100644 Session02/Session02/Session02.sln create mode 100644 Session02/Session02/Session02Excercise01/Program.cs create mode 100644 Session02/Session02/Session02Excercise01/Session02Excercise01.csproj diff --git a/Session02/Session02/Session02.sln b/Session02/Session02/Session02.sln new file mode 100644 index 0000000..44f26cd --- /dev/null +++ b/Session02/Session02/Session02.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}") = "Session02Excercise01", "Session02Excercise01\Session02Excercise01.csproj", "{19876383-95F1-4AF9-AED1-87B1940C5CA4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {29AF081A-69D3-4EEB-A68C-563945E90467} + EndGlobalSection +EndGlobal diff --git a/Session02/Session02/Session02Excercise01/Program.cs b/Session02/Session02/Session02Excercise01/Program.cs new file mode 100644 index 0000000..d138945 --- /dev/null +++ b/Session02/Session02/Session02Excercise01/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Session02Excercise01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/Session02/Session02/Session02Excercise01/Session02Excercise01.csproj b/Session02/Session02/Session02Excercise01/Session02Excercise01.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02/Session02Excercise01/Session02Excercise01.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + From 83ad73017eb2d24689be80ff5559ef7717ceb74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Wed, 26 Aug 2020 10:33:33 +0200 Subject: [PATCH 2/9] Comitted Integers Session02 --- Session02/Session02/Session02Excercise01/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session02/Session02/Session02Excercise01/Program.cs b/Session02/Session02/Session02Excercise01/Program.cs index d138945..ab3264c 100644 --- a/Session02/Session02/Session02Excercise01/Program.cs +++ b/Session02/Session02/Session02Excercise01/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 f9269998d8479caa81d095abf8ed52e752b9a746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Wed, 26 Aug 2020 10:38:39 +0200 Subject: [PATCH 3/9] stringtest --- Session02/Session02/Session02Excercise01/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session02/Session02/Session02Excercise01/Program.cs b/Session02/Session02/Session02Excercise01/Program.cs index d138945..b24d262 100644 --- a/Session02/Session02/Session02Excercise01/Program.cs +++ b/Session02/Session02/Session02Excercise01/Program.cs @@ -7,6 +7,10 @@ class Program static void Main(string[] args) { Console.WriteLine("Hello World!"); + + string stringValue = "MyStringValue"; + + Console.WriteLine("The value of stringValue is: " + stringValue); } } } From fc70cd02e1a0539238ec32b38656bd8c40a98141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Wed, 26 Aug 2020 11:52:46 +0200 Subject: [PATCH 4/9] Exercise 2 --- Session02/Session02/Session02.sln | 8 +++++- .../Session02/Session02Exercise02/Program.cs | 22 ++++++++++++++++ .../Session02Exercise02.csproj | 8 ++++++ .../Session02Exercise02/Program.cs | 23 +++++++++++++++++ .../Session02Exercise02.csproj | 8 ++++++ Session02/Session02ex02/Session02ex02.sln | 25 +++++++++++++++++++ 6 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 Session02/Session02/Session02Exercise02/Program.cs create mode 100644 Session02/Session02/Session02Exercise02/Session02Exercise02.csproj create mode 100644 Session02/Session02ex02/Session02Exercise02/Program.cs create mode 100644 Session02/Session02ex02/Session02Exercise02/Session02Exercise02.csproj create mode 100644 Session02/Session02ex02/Session02ex02.sln diff --git a/Session02/Session02/Session02.sln b/Session02/Session02/Session02.sln index 44f26cd..59c7663 100644 --- a/Session02/Session02/Session02.sln +++ b/Session02/Session02/Session02.sln @@ -3,7 +3,9 @@ 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}") = "Session02Excercise01", "Session02Excercise01\Session02Excercise01.csproj", "{19876383-95F1-4AF9-AED1-87B1940C5CA4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Excercise01", "Session02Excercise01\Session02Excercise01.csproj", "{19876383-95F1-4AF9-AED1-87B1940C5CA4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise02", "Session02Exercise02\Session02Exercise02.csproj", "{B6BA7FFB-6B0D-4079-B268-2E00DA25480D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Debug|Any CPU.Build.0 = Debug|Any CPU {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Release|Any CPU.ActiveCfg = Release|Any CPU {19876383-95F1-4AF9-AED1-87B1940C5CA4}.Release|Any CPU.Build.0 = Release|Any CPU + {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Session02/Session02/Session02Exercise02/Program.cs b/Session02/Session02/Session02Exercise02/Program.cs new file mode 100644 index 0000000..c83d1da --- /dev/null +++ b/Session02/Session02/Session02Exercise02/Program.cs @@ -0,0 +1,22 @@ +using System; +namespace Session02Exercise02 +{ + 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/Session02/Session02Exercise02/Session02Exercise02.csproj b/Session02/Session02/Session02Exercise02/Session02Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02/Session02Exercise02/Session02Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Session02ex02/Session02Exercise02/Program.cs b/Session02/Session02ex02/Session02Exercise02/Program.cs new file mode 100644 index 0000000..663b361 --- /dev/null +++ b/Session02/Session02ex02/Session02Exercise02/Program.cs @@ -0,0 +1,23 @@ +using System; + +namespace Session02Exercise02 +{ + 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/Session02ex02/Session02Exercise02/Session02Exercise02.csproj b/Session02/Session02ex02/Session02Exercise02/Session02Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02ex02/Session02Exercise02/Session02Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Session02ex02/Session02ex02.sln b/Session02/Session02ex02/Session02ex02.sln new file mode 100644 index 0000000..d6d2bb3 --- /dev/null +++ b/Session02/Session02ex02/Session02ex02.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}") = "Session02Exercise02", "Session02Exercise02\Session02Exercise02.csproj", "{B1019ED2-4FE5-428A-BBDE-C759C7A53C90}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1019ED2-4FE5-428A-BBDE-C759C7A53C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1019ED2-4FE5-428A-BBDE-C759C7A53C90}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1019ED2-4FE5-428A-BBDE-C759C7A53C90}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1019ED2-4FE5-428A-BBDE-C759C7A53C90}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {49EFCB3E-6855-4062-BC6E-F9B69B92A772} + EndGlobalSection +EndGlobal From cb065acd04b10662c2434efd06cddf86554a355d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Fri, 28 Aug 2020 09:16:32 +0200 Subject: [PATCH 5/9] Session 03 - Exercise 02 --- Session02/ConsoleApp1/ConsoleApp1.sln | 25 +++++++ .../ConsoleApp1/ConsoleApp1.csproj | 8 +++ Session02/ConsoleApp1/ConsoleApp1/Program.cs | 40 +++++++++++ .../Session02/ConsoleApp1/ConsoleApp1.csproj | 8 +++ Session02/Session02/ConsoleApp1/Program.cs | 71 +++++++++++++++++++ Session02/Session02/Session02.sln | 12 ++++ .../Session02/Session02Example04/Program.cs | 51 +++++++++++++ .../Session02Example04.csproj | 8 +++ Session02/Session03/Session03.sln | 25 +++++++ .../Session03/Session03Exercise02/Program.cs | 24 +++++++ .../Session03Exercise02.csproj | 8 +++ .../\303\226vningar lektion 3.sln" | 25 +++++++ .../\303\226vningar lektion 3/Program.cs" | 32 +++++++++ .../\303\226vningar lektion 3.csproj" | 9 +++ 14 files changed, 346 insertions(+) create mode 100644 Session02/ConsoleApp1/ConsoleApp1.sln create mode 100644 Session02/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj create mode 100644 Session02/ConsoleApp1/ConsoleApp1/Program.cs create mode 100644 Session02/Session02/ConsoleApp1/ConsoleApp1.csproj create mode 100644 Session02/Session02/ConsoleApp1/Program.cs create mode 100644 Session02/Session02/Session02Example04/Program.cs create mode 100644 Session02/Session02/Session02Example04/Session02Example04.csproj create mode 100644 Session02/Session03/Session03.sln create mode 100644 Session02/Session03/Session03Exercise02/Program.cs create mode 100644 Session02/Session03/Session03Exercise02/Session03Exercise02.csproj create mode 100644 "Session02/\303\226vningar lektion 3/\303\226vningar lektion 3.sln" create mode 100644 "Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" create mode 100644 "Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/\303\226vningar lektion 3.csproj" diff --git a/Session02/ConsoleApp1/ConsoleApp1.sln b/Session02/ConsoleApp1/ConsoleApp1.sln new file mode 100644 index 0000000..c9a397b --- /dev/null +++ b/Session02/ConsoleApp1/ConsoleApp1.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}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{0CDB9C9E-2F2C-4E95-9761-DA19DB872C5D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0CDB9C9E-2F2C-4E95-9761-DA19DB872C5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CDB9C9E-2F2C-4E95-9761-DA19DB872C5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CDB9C9E-2F2C-4E95-9761-DA19DB872C5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CDB9C9E-2F2C-4E95-9761-DA19DB872C5D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4025A1B4-422B-40C7-9624-54D828A1EA67} + EndGlobalSection +EndGlobal diff --git a/Session02/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj b/Session02/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/ConsoleApp1/ConsoleApp1/Program.cs b/Session02/ConsoleApp1/ConsoleApp1/Program.cs new file mode 100644 index 0000000..b23b735 --- /dev/null +++ b/Session02/ConsoleApp1/ConsoleApp1/Program.cs @@ -0,0 +1,40 @@ +using System; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + var integerValues = new[] { 1, 2, 3 }; + var name = nameof(integerValues); + Console.WriteLine("For-loop"); + for (var i = 0; i < integerValues.Length; i++) + { + var value = integerValues[i]; + + Console.WriteLine($"Index {i} i arrayen {name} har värdet: {value}"); + } + Console.WriteLine(); + Console.WriteLine("Do-while-loop"); + var doWhileIndex = 0; + do + { + var value = integerValues[doWhileIndex]; + Console.WriteLine($"Index {doWhileIndex} i arrayen {name} har värdet: {value}"); + doWhileIndex++; + } + while (doWhileIndex < integerValues.Length); + + var whileIndex = 0; + Console.WriteLine(); + Console.WriteLine("While-loop"); + while(whileIndex < integerValues.Length) + { + var value = integerValues[whileIndex]; + Console.WriteLine($"Index {whileIndex} i arrayen {name} har värdet: {value}"); + whileIndex++; + } + } + } +} diff --git a/Session02/Session02/ConsoleApp1/ConsoleApp1.csproj b/Session02/Session02/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Session02/ConsoleApp1/Program.cs b/Session02/Session02/ConsoleApp1/Program.cs new file mode 100644 index 0000000..8997572 --- /dev/null +++ b/Session02/Session02/ConsoleApp1/Program.cs @@ -0,0 +1,71 @@ +using System; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + var additionResult = 1 + 2; + Console.WriteLine("Additionresult: " + additionResult); + var incrementResult1 = additionResult++; + var incrementResult2 = ++additionResult; + Console.WriteLine("incrementresult: " + incrementResult1); + Console.WriteLine("incrementresult: " + incrementResult2); + + var trueValue = true; + var falseValue = false; + + // Inte boolsk jämförelse + var andResult = 0b0010 & 0b0100; // 0b0110 + var orResult = trueValue | falseValue; + var xorResult = trueValue ^ falseValue; + + Console.WriteLine("andResult: " + andResult); + Console.WriteLine("orResult: " + orResult); + Console.WriteLine("xorValue: " + xorResult); + + var moduleResult = 3 % 2; + + Console.WriteLine("ModuleResult: " + moduleResult); + + var highInteger = 1000; + var divisionResult = highInteger / 3; + // Implicit värdekonvertering till double + var doubleDivisionResult = highInteger / 3.0; + + var forcedIntDivisionResult = (int)(highInteger / 3.0); + + Console.WriteLine("DivisionResult: " + divisionResult); + Console.WriteLine("DoubleDivisionResult: " + doubleDivisionResult); + Console.WriteLine("forcedIntDivisionResult: " + forcedIntDivisionResult); + + var conversionResult = Convert.ToInt32(doubleDivisionResult); + Console.WriteLine("conversionResult: " + conversionResult); + + var midpointDivisionResult = 1.0 / 3.0; + + Console.WriteLine("midpointDivisionResult: " + midpointDivisionResult); + Console.WriteLine("castToInt: " + ((int)midpointDivisionResult)); + Console.WriteLine("Ceiling: " + Math.Ceiling(midpointDivisionResult)); + Console.WriteLine("Floor: " + Math.Floor(midpointDivisionResult)); + Console.WriteLine("Round: " + Math.Round(midpointDivisionResult, 3)); + + //Det går även att använda sammanslagna operatorer + // -= + // += + // *= + // /= + + // Finns även <=, >=, ==, + var greaterResult = 5 > 3; + var lessThanResult = 5 < 3; + + Console.WriteLine("greaterThanREsult: " + greaterResult); + Console.WriteLine("lessThanResult: " + lessThanResult); + + + + } + } +} diff --git a/Session02/Session02/Session02.sln b/Session02/Session02/Session02.sln index 59c7663..c9e2134 100644 --- a/Session02/Session02/Session02.sln +++ b/Session02/Session02/Session02.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Excercise01", "Ses EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Exercise02", "Session02Exercise02\Session02Exercise02.csproj", "{B6BA7FFB-6B0D-4079-B268-2E00DA25480D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{FABF555D-DB61-4EE6-AD9F-A6FC603412FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session02Example04", "Session02Example04\Session02Example04.csproj", "{18E7D114-46CA-494E-819B-031C8EC8420D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +25,14 @@ Global {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6BA7FFB-6B0D-4079-B268-2E00DA25480D}.Release|Any CPU.Build.0 = Release|Any CPU + {FABF555D-DB61-4EE6-AD9F-A6FC603412FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FABF555D-DB61-4EE6-AD9F-A6FC603412FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FABF555D-DB61-4EE6-AD9F-A6FC603412FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FABF555D-DB61-4EE6-AD9F-A6FC603412FB}.Release|Any CPU.Build.0 = Release|Any CPU + {18E7D114-46CA-494E-819B-031C8EC8420D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18E7D114-46CA-494E-819B-031C8EC8420D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18E7D114-46CA-494E-819B-031C8EC8420D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18E7D114-46CA-494E-819B-031C8EC8420D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Session02/Session02/Session02Example04/Program.cs b/Session02/Session02/Session02Example04/Program.cs new file mode 100644 index 0000000..cc571c2 --- /dev/null +++ b/Session02/Session02/Session02Example04/Program.cs @@ -0,0 +1,51 @@ +using System; + +namespace Session02Example04 +{ + 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 jättegammal"); + } + + Console.WriteLine("Ange vattentemperatur i grader C: "); + var input1 = Console.ReadLine(); + var integer1 = Convert.ToInt32(input1); + + string waterLabel = integer1 >= 27 ? "Går att bada" : "Går inte att bada"; + //if (integer1 >= 27) + //{ + //Console.WriteLine("Går att bada"); + //} + //else + //{ + // Console.WriteLine("Det går inte att bada"); + //} + + switch (integer1) + { + case 1: waterLabel = "Går inte att bada alls"; break; + case -3: waterLabel = "Det är 3 minusgrader"; break; + } + Console.WriteLine(waterLabel + " i havet"); + + + } + } +} diff --git a/Session02/Session02/Session02Example04/Session02Example04.csproj b/Session02/Session02/Session02Example04/Session02Example04.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session02/Session02Example04/Session02Example04.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/Session02/Session03/Session03.sln b/Session02/Session03/Session03.sln new file mode 100644 index 0000000..ac4a069 --- /dev/null +++ b/Session02/Session03/Session03.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}") = "Session03Exercise02", "Session03Exercise02\Session03Exercise02.csproj", "{8BDD4CF9-8135-44E8-8604-0650A7FD6D28}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8BDD4CF9-8135-44E8-8604-0650A7FD6D28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8BDD4CF9-8135-44E8-8604-0650A7FD6D28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8BDD4CF9-8135-44E8-8604-0650A7FD6D28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8BDD4CF9-8135-44E8-8604-0650A7FD6D28}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CBE1BF82-DE25-495C-B0C8-733790FC6FDE} + EndGlobalSection +EndGlobal diff --git a/Session02/Session03/Session03Exercise02/Program.cs b/Session02/Session03/Session03Exercise02/Program.cs new file mode 100644 index 0000000..8dd3186 --- /dev/null +++ b/Session02/Session03/Session03Exercise02/Program.cs @@ -0,0 +1,24 @@ +using System; + +namespace Session03Exercise02 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Ange ett antal siffror, separerat med kommatecken."); + var input = Console.ReadLine(); + + //Alternativt var inputArray = input.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries); + var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); + + int total = 0; + + foreach (var number in inputArray) + { + Console.WriteLine("Värdet är " + number); + total += Convert.ToInt32(number); + } + } + } +} diff --git a/Session02/Session03/Session03Exercise02/Session03Exercise02.csproj b/Session02/Session03/Session03Exercise02/Session03Exercise02.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/Session02/Session03/Session03Exercise02/Session03Exercise02.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git "a/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3.sln" "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3.sln" new file mode 100644 index 0000000..680df0c --- /dev/null +++ "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3.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}") = "Övningar lektion 3", "Övningar lektion 3\Övningar lektion 3.csproj", "{20FC56F0-46EC-47DD-9079-C7452C7C0C27}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {20FC56F0-46EC-47DD-9079-C7452C7C0C27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20FC56F0-46EC-47DD-9079-C7452C7C0C27}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20FC56F0-46EC-47DD-9079-C7452C7C0C27}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20FC56F0-46EC-47DD-9079-C7452C7C0C27}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {96358039-F896-4E90-AFFC-E49A05F34BA1} + EndGlobalSection +EndGlobal diff --git "a/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" new file mode 100644 index 0000000..974a6d9 --- /dev/null +++ "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" @@ -0,0 +1,32 @@ +using System; + +namespace Övningar_lektion_3 +{ + class Program + { + static void Main(string[] args) + { + // Övning 1 + /*Console.WriteLine("Input value 1:"); + int input1 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Input value 2:"); + int input2 = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine(); + for (int i = input1 + 1; i < input2; i++) + { + Console.WriteLine(i); + } + */ + // Övning 2 + //int schack = 12; + for (int i = 0; i < 12; i += 2) + { + int test = i %= 2; + if(test == 1) + Console.WriteLine('░'); + else + Console.WriteLine('▓'); + } + } + } +} diff --git "a/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/\303\226vningar lektion 3.csproj" "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/\303\226vningar lektion 3.csproj" new file mode 100644 index 0000000..982ec1d --- /dev/null +++ "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/\303\226vningar lektion 3.csproj" @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp3.1 + Övningar_lektion_3 + + + From 292ae35173359120263d38d4b65cf37e7297a33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Fri, 28 Aug 2020 13:08:30 +0200 Subject: [PATCH 6/9] Progress on number app --- .../Session03/Session03Exercise02/Program.cs | 113 +++++++++++++++++- .../\303\226vningar lektion 3/Program.cs" | 36 ++++-- 2 files changed, 139 insertions(+), 10 deletions(-) diff --git a/Session02/Session03/Session03Exercise02/Program.cs b/Session02/Session03/Session03Exercise02/Program.cs index 8dd3186..b73dd79 100644 --- a/Session02/Session03/Session03Exercise02/Program.cs +++ b/Session02/Session03/Session03Exercise02/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; namespace Session03Exercise02 { @@ -8,17 +9,123 @@ static void Main(string[] args) { Console.WriteLine("Ange ett antal siffror, separerat med kommatecken."); var input = Console.ReadLine(); - - //Alternativt var inputArray = input.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries); + Console.WriteLine(); + // Alternativt var inputArray = input.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries); var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); - + IFormatProvider formatProvider = + #region min grej + /* int total = 0; + int loops = 0; + int maxValue = 0; + int minValue = Convert.ToInt32(inputArray[0]); + int testValue; foreach (var number in inputArray) { Console.WriteLine("Värdet är " + number); + + testValue = Convert.ToInt32(number); + if (maxValue < testValue) + { + maxValue = testValue; + } + + if (minValue > testValue) + { + minValue = testValue; + } + total += Convert.ToInt32(number); + loops++; + } + Console.WriteLine(); + Console.WriteLine("Medelvärdet är: " + total/loops); + Console.WriteLine(); + Console.WriteLine("Max värdet är: " + maxValue); + Console.WriteLine(); + Console.WriteLine("Min värdet är: " + minValue); + */ + #endregion + double? [] array = new double?[inputArray.Length]; + #region min andra grej + /* + for (int i = 0; i testValue) + { + minValue = testValue; + } + + total += number; + loops++; } + Console.WriteLine(); + Console.WriteLine("Medelvärdet är: " + total / loops); + Console.WriteLine(); + Console.WriteLine("Max värdet är: " + maxValue); + Console.WriteLine(); + Console.WriteLine("Min värdet är: " + minValue); } } } diff --git "a/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" index 974a6d9..47043bb 100644 --- "a/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" +++ "b/Session02/\303\226vningar lektion 3/\303\226vningar lektion 3/Program.cs" @@ -18,14 +18,36 @@ static void Main(string[] args) } */ // Övning 2 - //int schack = 12; - for (int i = 0; i < 12; i += 2) + for (int i = 1; i < 65; i++) { - int test = i %= 2; - if(test == 1) - Console.WriteLine('░'); - else - Console.WriteLine('▓'); + int test = i % 2; + int lineBreak = i % 8; + int lineSwitch = 1; + + if (lineSwitch % 2 == 1) + { + if (lineBreak == 1) + { + Console.Write("\n"); + lineSwitch++; + } + if (test == 1) + Console.Write('▓'); + else + Console.Write('░'); + } + else if (lineSwitch % 2 == 0) + { + if (lineBreak == 1) + { + Console.Write("\n"); + lineSwitch++; + } + if (test == 0) + Console.Write('▓'); + else + Console.Write('░'); + } } } } From 5fd872b036da7db4506a0f4590bcfde5c69da63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Fri, 28 Aug 2020 13:13:53 +0200 Subject: [PATCH 7/9] klar --- Session02/Session03/Session03Exercise02/Program.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Session02/Session03/Session03Exercise02/Program.cs b/Session02/Session03/Session03Exercise02/Program.cs index b73dd79..0e958b7 100644 --- a/Session02/Session03/Session03Exercise02/Program.cs +++ b/Session02/Session03/Session03Exercise02/Program.cs @@ -12,7 +12,7 @@ static void Main(string[] args) Console.WriteLine(); // Alternativt var inputArray = input.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries); var inputArray = input.Split(",", StringSplitOptions.RemoveEmptyEntries); - IFormatProvider formatProvider = + #region min grej /* int total = 0; @@ -66,9 +66,8 @@ static void Main(string[] args) #endregion for (int i = 0; i < inputArray.Length; i++) { - #region Bortkommenterat - NumberStyles numberStyle = NumberStyles.Integer | NumberStyles.Float; + IFormatProvider formatProvider = CultureInfo.InvariantCulture; bool parsed = double.TryParse(inputArray[i], numberStyle, formatProvider, out double parsedValue); if (parsed == true) @@ -80,8 +79,6 @@ static void Main(string[] args) Console.WriteLine("!"); array[i] = null; } - - #endregion #region try catch /*try { @@ -101,12 +98,11 @@ static void Main(string[] args) double? minValue = array[0]; double? testValue; - foreach (var number in array) { Console.WriteLine("Värdet är " + number); - testValue = number; + if (maxValue < testValue) { maxValue = testValue; From 3c2c70516d7210f3013ad0d32058a00384185aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Fri, 28 Aug 2020 13:35:19 +0200 Subject: [PATCH 8/9] Fixed null a bit --- Session02/Session03/Session03Exercise02/Program.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Session02/Session03/Session03Exercise02/Program.cs b/Session02/Session03/Session03Exercise02/Program.cs index 0e958b7..82724b2 100644 --- a/Session02/Session03/Session03Exercise02/Program.cs +++ b/Session02/Session03/Session03Exercise02/Program.cs @@ -100,6 +100,11 @@ static void Main(string[] args) foreach (var number in array) { + if(number == null) + { + Console.WriteLine("The value is null"); + continue; + } Console.WriteLine("Värdet är " + number); testValue = number; From 463be58e9a8a084e7a29dfcbb68c7e9a4e5cb55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Zon=C3=A9?= Date: Fri, 28 Aug 2020 13:50:31 +0200 Subject: [PATCH 9/9] =?UTF-8?q?=C3=84ndringar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Session02/Session03/Session03Exercise02/Program.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Session02/Session03/Session03Exercise02/Program.cs b/Session02/Session03/Session03Exercise02/Program.cs index 82724b2..3f908e7 100644 --- a/Session02/Session03/Session03Exercise02/Program.cs +++ b/Session02/Session03/Session03Exercise02/Program.cs @@ -76,7 +76,6 @@ static void Main(string[] args) } else { - Console.WriteLine("!"); array[i] = null; } #region try catch @@ -124,9 +123,9 @@ static void Main(string[] args) Console.WriteLine(); Console.WriteLine("Medelvärdet är: " + total / loops); Console.WriteLine(); - Console.WriteLine("Max värdet är: " + maxValue); + Console.WriteLine("Det högsta värdet är: " + maxValue); Console.WriteLine(); - Console.WriteLine("Min värdet är: " + minValue); + Console.WriteLine("Det minsta värdet är: " + minValue); } } }