From a8aaec9aa0674fd9938ba81f333641481be6e645 Mon Sep 17 00:00:00 2001 From: di7chro Date: Thu, 18 Jun 2015 10:54:28 +0200 Subject: [PATCH] Second day --- Anonymous/Anonymous/App.config | 6 ++ Excercise7/Excercise7.sln | 22 +++++ Excercise7/Excercise7/App.config | 6 ++ Excercise7/Excercise7/Excercise7.csproj | 60 ++++++++++++ Excercise7/Excercise7/Program.cs | 43 +++++++++ .../Excercise7/Properties/AssemblyInfo.cs | 36 ++++++++ Excercise7/Excercise7/Weight.cs | 91 +++++++++++++++++++ Excercise7/Excercise7/WeightUnit.cs | 16 ++++ Excersise2A/Excersise2A.sln | 22 +++++ Excersise2A/Excersise2A/App.config | 6 ++ Excersise2A/Excersise2A/CustomStack.cs | 38 ++++++++ Excersise2A/Excersise2A/Excersise2A.csproj | 59 ++++++++++++ Excersise2A/Excersise2A/Program.cs | 44 +++++++++ .../Excersise2A/Properties/AssemblyInfo.cs | 36 ++++++++ Excersise3/Excersise3.sln | 22 +++++ Excersise3/Excersise3/App.config | 6 ++ Excersise3/Excersise3/Excersise3.csproj | 59 ++++++++++++ Excersise3/Excersise3/ListLoader.cs | 23 +++++ Excersise3/Excersise3/Program.cs | 36 ++++++++ .../Excersise3/Properties/AssemblyInfo.cs | 36 ++++++++ Excersise4/Excersise4.sln | 22 +++++ Excersise4/Excersise4/App.config | 6 ++ Excersise4/Excersise4/Excersise4.csproj | 60 ++++++++++++ Excersise4/Excersise4/LanguageData.cs | 15 +++ Excersise4/Excersise4/ListLoader.cs | 33 +++++++ Excersise4/Excersise4/Program.cs | 40 ++++++++ .../Excersise4/Properties/AssemblyInfo.cs | 36 ++++++++ Exercise5/Exercise5.sln | 22 +++++ Exercise5/Exercise5/App.config | 6 ++ Exercise5/Exercise5/Exercise5.csproj | 60 ++++++++++++ Exercise5/Exercise5/Program.cs | 46 ++++++++++ .../Exercise5/Properties/AssemblyInfo.cs | 36 ++++++++ Exercise5/Exercise5/Weight.cs | 72 +++++++++++++++ Exercise5/Exercise5/WeightUnit.cs | 16 ++++ Exercise6/Exercise6.sln | 22 +++++ Exercise6/Exercise6/App.config | 6 ++ Exercise6/Exercise6/CustomStack.cs | 56 ++++++++++++ Exercise6/Exercise6/Exercise6.csproj | 59 ++++++++++++ Exercise6/Exercise6/Program.cs | 58 ++++++++++++ .../Exercise6/Properties/AssemblyInfo.cs | 36 ++++++++ Exercise8/Exercise8.sln | 22 +++++ Exercise8/Exercise8/App.config | 6 ++ Exercise8/Exercise8/Exercise8.csproj | 61 +++++++++++++ Exercise8/Exercise8/Program.cs | 29 ++++++ .../Exercise8/Properties/AssemblyInfo.cs | 36 ++++++++ Exercise8/Exercise8/Weight.cs | 91 +++++++++++++++++++ Exercise8/Exercise8/WeightExtensions.cs | 34 +++++++ Exercise8/Exercise8/WeightUnit.cs | 16 ++++ Exercise9A/Exercise9A.sln | 22 +++++ Exercise9A/Exercise9A/App.config | 6 ++ Exercise9A/Exercise9A/Calculator.cs | 15 +++ Exercise9A/Exercise9A/Exercise9A.csproj | 59 ++++++++++++ Exercise9A/Exercise9A/Program.cs | 28 ++++++ .../Exercise9A/Properties/AssemblyInfo.cs | 36 ++++++++ Exercise9B/Exercise9B.sln | 22 +++++ Exercise9B/Exercise9B/App.config | 6 ++ Exercise9B/Exercise9B/Exercise9B.csproj | 58 ++++++++++++ Exercise9B/Exercise9B/Program.cs | 52 +++++++++++ .../Exercise9B/Properties/AssemblyInfo.cs | 36 ++++++++ SlideTester/SlideTester.sln | 22 +++++ SlideTester/SlideTester/App.config | 6 ++ SlideTester/SlideTester/Program.cs | 39 ++++++++ .../SlideTester/Properties/AssemblyInfo.cs | 36 ++++++++ SlideTester/SlideTester/SlideTester.csproj | 58 ++++++++++++ Structs/ConsoleSlask.sln | 22 +++++ Structs/ConsoleSlask/App.config | 6 ++ Structs/ConsoleSlask/ConsoleSlask.csproj | 58 ++++++++++++ Structs/ConsoleSlask/Program.cs | 43 +++++++++ .../ConsoleSlask/Properties/AssemblyInfo.cs | 36 ++++++++ 69 files changed, 2335 insertions(+) create mode 100644 Anonymous/Anonymous/App.config create mode 100644 Excercise7/Excercise7.sln create mode 100644 Excercise7/Excercise7/App.config create mode 100644 Excercise7/Excercise7/Excercise7.csproj create mode 100644 Excercise7/Excercise7/Program.cs create mode 100644 Excercise7/Excercise7/Properties/AssemblyInfo.cs create mode 100644 Excercise7/Excercise7/Weight.cs create mode 100644 Excercise7/Excercise7/WeightUnit.cs create mode 100644 Excersise2A/Excersise2A.sln create mode 100644 Excersise2A/Excersise2A/App.config create mode 100644 Excersise2A/Excersise2A/CustomStack.cs create mode 100644 Excersise2A/Excersise2A/Excersise2A.csproj create mode 100644 Excersise2A/Excersise2A/Program.cs create mode 100644 Excersise2A/Excersise2A/Properties/AssemblyInfo.cs create mode 100644 Excersise3/Excersise3.sln create mode 100644 Excersise3/Excersise3/App.config create mode 100644 Excersise3/Excersise3/Excersise3.csproj create mode 100644 Excersise3/Excersise3/ListLoader.cs create mode 100644 Excersise3/Excersise3/Program.cs create mode 100644 Excersise3/Excersise3/Properties/AssemblyInfo.cs create mode 100644 Excersise4/Excersise4.sln create mode 100644 Excersise4/Excersise4/App.config create mode 100644 Excersise4/Excersise4/Excersise4.csproj create mode 100644 Excersise4/Excersise4/LanguageData.cs create mode 100644 Excersise4/Excersise4/ListLoader.cs create mode 100644 Excersise4/Excersise4/Program.cs create mode 100644 Excersise4/Excersise4/Properties/AssemblyInfo.cs create mode 100644 Exercise5/Exercise5.sln create mode 100644 Exercise5/Exercise5/App.config create mode 100644 Exercise5/Exercise5/Exercise5.csproj create mode 100644 Exercise5/Exercise5/Program.cs create mode 100644 Exercise5/Exercise5/Properties/AssemblyInfo.cs create mode 100644 Exercise5/Exercise5/Weight.cs create mode 100644 Exercise5/Exercise5/WeightUnit.cs create mode 100644 Exercise6/Exercise6.sln create mode 100644 Exercise6/Exercise6/App.config create mode 100644 Exercise6/Exercise6/CustomStack.cs create mode 100644 Exercise6/Exercise6/Exercise6.csproj create mode 100644 Exercise6/Exercise6/Program.cs create mode 100644 Exercise6/Exercise6/Properties/AssemblyInfo.cs create mode 100644 Exercise8/Exercise8.sln create mode 100644 Exercise8/Exercise8/App.config create mode 100644 Exercise8/Exercise8/Exercise8.csproj create mode 100644 Exercise8/Exercise8/Program.cs create mode 100644 Exercise8/Exercise8/Properties/AssemblyInfo.cs create mode 100644 Exercise8/Exercise8/Weight.cs create mode 100644 Exercise8/Exercise8/WeightExtensions.cs create mode 100644 Exercise8/Exercise8/WeightUnit.cs create mode 100644 Exercise9A/Exercise9A.sln create mode 100644 Exercise9A/Exercise9A/App.config create mode 100644 Exercise9A/Exercise9A/Calculator.cs create mode 100644 Exercise9A/Exercise9A/Exercise9A.csproj create mode 100644 Exercise9A/Exercise9A/Program.cs create mode 100644 Exercise9A/Exercise9A/Properties/AssemblyInfo.cs create mode 100644 Exercise9B/Exercise9B.sln create mode 100644 Exercise9B/Exercise9B/App.config create mode 100644 Exercise9B/Exercise9B/Exercise9B.csproj create mode 100644 Exercise9B/Exercise9B/Program.cs create mode 100644 Exercise9B/Exercise9B/Properties/AssemblyInfo.cs create mode 100644 SlideTester/SlideTester.sln create mode 100644 SlideTester/SlideTester/App.config create mode 100644 SlideTester/SlideTester/Program.cs create mode 100644 SlideTester/SlideTester/Properties/AssemblyInfo.cs create mode 100644 SlideTester/SlideTester/SlideTester.csproj create mode 100644 Structs/ConsoleSlask.sln create mode 100644 Structs/ConsoleSlask/App.config create mode 100644 Structs/ConsoleSlask/ConsoleSlask.csproj create mode 100644 Structs/ConsoleSlask/Program.cs create mode 100644 Structs/ConsoleSlask/Properties/AssemblyInfo.cs diff --git a/Anonymous/Anonymous/App.config b/Anonymous/Anonymous/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Anonymous/Anonymous/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Excercise7/Excercise7.sln b/Excercise7/Excercise7.sln new file mode 100644 index 0000000..1760165 --- /dev/null +++ b/Excercise7/Excercise7.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excercise7", "Excercise7\Excercise7.csproj", "{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Excercise7/Excercise7/App.config b/Excercise7/Excercise7/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Excercise7/Excercise7/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Excercise7/Excercise7/Excercise7.csproj b/Excercise7/Excercise7/Excercise7.csproj new file mode 100644 index 0000000..1cc75f3 --- /dev/null +++ b/Excercise7/Excercise7/Excercise7.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1} + Exe + Properties + Excercise7 + Excercise7 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Excercise7/Excercise7/Program.cs b/Excercise7/Excercise7/Program.cs new file mode 100644 index 0000000..ca6b9b4 --- /dev/null +++ b/Excercise7/Excercise7/Program.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Exercise5; + +namespace Excercise7 +{ + class Program + { + static void Main(string[] args) + { + // wFirst and wSecond are Weight-instances + Weight wFirst = new Weight(); + Weight wSecond = new Weight(); + + wFirst.SetWeight(WeightUnit.Kilogram, 50); + wSecond.SetWeight(WeightUnit.Kilogram, 60); + + var first = wFirst.GetWeight(WeightUnit.Kilogram); + + wSecond.Add(wFirst); + Console.WriteLine(wSecond.GetWeight(WeightUnit.Kilogram)); + + wSecond.SetWeight(wFirst); + Console.WriteLine(wSecond.GetWeight(WeightUnit.Kilogram)); + + var wResult = wFirst + wSecond; + Console.WriteLine(wResult.GetWeight(WeightUnit.Kilogram)); + + WaitForInput(); + + } + + private static void WaitForInput() + { + Console.WriteLine("\nPress enter..."); + Console.ReadLine(); + } + + } +} diff --git a/Excercise7/Excercise7/Properties/AssemblyInfo.cs b/Excercise7/Excercise7/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..628eb4c --- /dev/null +++ b/Excercise7/Excercise7/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excercise7")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Excercise7")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("44aeb9fa-21aa-4249-87ab-2325924dca14")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Excercise7/Excercise7/Weight.cs b/Excercise7/Excercise7/Weight.cs new file mode 100644 index 0000000..1586b0a --- /dev/null +++ b/Excercise7/Excercise7/Weight.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Exercise5 +{ + class Weight + { + private double weight = 0; // Nullable Type + + public void SetWeight(WeightUnit weightUnit, double p) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + weight = p; + break; + case WeightUnit.Pound: + weight = p * 0.45359237; + break; + case WeightUnit.Gram: + weight = p / 1000; + break; + case WeightUnit.Ounce: + weight = p * 0.0283495231; + break; + } + } + + public void Add(WeightUnit weightUnit, double p) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + weight += p; + break; + case WeightUnit.Pound: + weight += p * 0.45359237; + break; + case WeightUnit.Gram: + weight = p / 1000; + break; + case WeightUnit.Ounce: + weight = p * 0.0283495231; + break; + } + } + + public double GetWeight(WeightUnit weightUnit) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + return weight; + break; + case WeightUnit.Pound: + return (weight*2.20462262); + break; + case WeightUnit.Gram: + return (weight * 1000); + break; + case WeightUnit.Ounce: + return (weight * 35.2739619); + break; + default: + throw new NotImplementedException(); + break; + } + } + + public void Add(Weight w) + { + weight += w.GetWeight(WeightUnit.Kilogram); + } + + public void SetWeight(Weight w) + { + SetWeight(WeightUnit.Kilogram, w.GetWeight(WeightUnit.Kilogram)); + } + + public static Weight operator +(Weight leftWeight, Weight rightWeight) + { + Weight sumWeight = new Weight(); + + sumWeight.SetWeight(WeightUnit.Kilogram, leftWeight.GetWeight(WeightUnit.Kilogram) + rightWeight.GetWeight(WeightUnit.Kilogram)); + + return sumWeight; + } + } +} diff --git a/Excercise7/Excercise7/WeightUnit.cs b/Excercise7/Excercise7/WeightUnit.cs new file mode 100644 index 0000000..ef1e6b1 --- /dev/null +++ b/Excercise7/Excercise7/WeightUnit.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Exercise5 +{ + + public enum WeightUnit : long + { + Kilogram, + Gram, + Pound, + Ounce + } +} diff --git a/Excersise2A/Excersise2A.sln b/Excersise2A/Excersise2A.sln new file mode 100644 index 0000000..c880a19 --- /dev/null +++ b/Excersise2A/Excersise2A.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excersise2A", "Excersise2A\Excersise2A.csproj", "{6685944B-FD6B-4C3D-82ED-7625749F08AF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6685944B-FD6B-4C3D-82ED-7625749F08AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6685944B-FD6B-4C3D-82ED-7625749F08AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6685944B-FD6B-4C3D-82ED-7625749F08AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6685944B-FD6B-4C3D-82ED-7625749F08AF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Excersise2A/Excersise2A/App.config b/Excersise2A/Excersise2A/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Excersise2A/Excersise2A/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Excersise2A/Excersise2A/CustomStack.cs b/Excersise2A/Excersise2A/CustomStack.cs new file mode 100644 index 0000000..ad5b9c0 --- /dev/null +++ b/Excersise2A/Excersise2A/CustomStack.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Excersise2A +{ + class CustomStack + { + private List items = new List(); + + public T Peek() + { + T item = items[0]; + return item; + } + public T Pop() + { + T item = items[0]; + items.RemoveAt(0); + return item; + } + public T Push(T item) + { + items.Insert(0, item); + return item; + } + + private bool isEmpty() + { + if (items.Count == 0) + return true; + else + return false; + } + } +} diff --git a/Excersise2A/Excersise2A/Excersise2A.csproj b/Excersise2A/Excersise2A/Excersise2A.csproj new file mode 100644 index 0000000..cfab520 --- /dev/null +++ b/Excersise2A/Excersise2A/Excersise2A.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {6685944B-FD6B-4C3D-82ED-7625749F08AF} + Exe + Properties + Excersise2A + Excersise2A + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Excersise2A/Excersise2A/Program.cs b/Excersise2A/Excersise2A/Program.cs new file mode 100644 index 0000000..6082fd6 --- /dev/null +++ b/Excersise2A/Excersise2A/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Excersise2A +{ + class Program + { + static void Main(string[] args) + { + CustomStack intStack = new CustomStack(); + CustomStack stringStack = new CustomStack(); + + /* ------ INT-STACK --------------- */ + intStack.Push(14); + intStack.Push(23); + intStack.Push(34); + intStack.Push(46); + Console.WriteLine(intStack.Peek()); + + intStack.Pop(); + Console.WriteLine(intStack.Peek()); + + /* ------ STRING-STACK --------------- */ + stringStack.Push("Anna"); + stringStack.Push("Bertil"); + stringStack.Push("Ceasar"); + Console.WriteLine(stringStack.Peek()); + + stringStack.Pop(); + Console.WriteLine(stringStack.Peek()); + + + WaitForInput(); + } + static void WaitForInput() + { + Console.WriteLine("Press Enter..."); + Console.ReadLine(); + } + } +} diff --git a/Excersise2A/Excersise2A/Properties/AssemblyInfo.cs b/Excersise2A/Excersise2A/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..475a50d --- /dev/null +++ b/Excersise2A/Excersise2A/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excersise2A")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Excersise2A")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6591cb97-6bbf-48b1-8cac-18d0687aab66")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Excersise3/Excersise3.sln b/Excersise3/Excersise3.sln new file mode 100644 index 0000000..7412971 --- /dev/null +++ b/Excersise3/Excersise3.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excersise3", "Excersise3\Excersise3.csproj", "{E5508F12-33D7-48BC-B740-46E91846C506}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E5508F12-33D7-48BC-B740-46E91846C506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5508F12-33D7-48BC-B740-46E91846C506}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5508F12-33D7-48BC-B740-46E91846C506}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5508F12-33D7-48BC-B740-46E91846C506}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Excersise3/Excersise3/App.config b/Excersise3/Excersise3/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Excersise3/Excersise3/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Excersise3/Excersise3/Excersise3.csproj b/Excersise3/Excersise3/Excersise3.csproj new file mode 100644 index 0000000..9ef8919 --- /dev/null +++ b/Excersise3/Excersise3/Excersise3.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {E5508F12-33D7-48BC-B740-46E91846C506} + Exe + Properties + Excersise3 + Excersise3 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Excersise3/Excersise3/ListLoader.cs b/Excersise3/Excersise3/ListLoader.cs new file mode 100644 index 0000000..8c454d1 --- /dev/null +++ b/Excersise3/Excersise3/ListLoader.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.IO; + +namespace Excersise3 +{ + public class ListLoader + { + public List LoadListFromFile(string fileName) + { + var list = new List(); + var sr = new StreamReader(fileName); + var line = string.Empty; + + while ((line = sr.ReadLine()) != null) + { + list.Add(line); + } + + sr.Close(); + return list; + } + } +} \ No newline at end of file diff --git a/Excersise3/Excersise3/Program.cs b/Excersise3/Excersise3/Program.cs new file mode 100644 index 0000000..0b006c9 --- /dev/null +++ b/Excersise3/Excersise3/Program.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Excersise3 +{ + class Program + { + static void Main() + { + ListLoader myLoader = new ListLoader(); + List languages = new List(); + + languages = myLoader.LoadListFromFile("languages.txt"); + + Console.Write("List languages containing: "); + string searchFor = Console.ReadLine(); + + var result = from a in languages + where a.ToLower().Contains(searchFor.ToLower()) + select a; + + foreach (var item in result) + { + Console.WriteLine(item); + } + WaitForInput(); + } + + static void WaitForInput() + { + Console.WriteLine("Press Enter..."); + Console.ReadLine(); + } + } +} diff --git a/Excersise3/Excersise3/Properties/AssemblyInfo.cs b/Excersise3/Excersise3/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..100ce76 --- /dev/null +++ b/Excersise3/Excersise3/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excersise3")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Excersise3")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fc9c7672-9abd-4040-aa81-2777019590db")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Excersise4/Excersise4.sln b/Excersise4/Excersise4.sln new file mode 100644 index 0000000..0ddec37 --- /dev/null +++ b/Excersise4/Excersise4.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excersise4", "Excersise4\Excersise4.csproj", "{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Excersise4/Excersise4/App.config b/Excersise4/Excersise4/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Excersise4/Excersise4/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Excersise4/Excersise4/Excersise4.csproj b/Excersise4/Excersise4/Excersise4.csproj new file mode 100644 index 0000000..4f2760c --- /dev/null +++ b/Excersise4/Excersise4/Excersise4.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {D2DA5FD4-C060-4394-B0B8-0A851DD44B12} + Exe + Properties + Excersise4 + Excersise4 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Excersise4/Excersise4/LanguageData.cs b/Excersise4/Excersise4/LanguageData.cs new file mode 100644 index 0000000..ab3d6c7 --- /dev/null +++ b/Excersise4/Excersise4/LanguageData.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Excersise4 +{ + class LanguageData + { + public string Name; + public int Year; + public string Description; + } +} diff --git a/Excersise4/Excersise4/ListLoader.cs b/Excersise4/Excersise4/ListLoader.cs new file mode 100644 index 0000000..c40e415 --- /dev/null +++ b/Excersise4/Excersise4/ListLoader.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Excersise4 +{ + class ListLoader + { + public List LoadListFromFile(string fileName) + { + var list = new List(); + var sr = new StreamReader(fileName); + var line = string.Empty; + + while ((line = sr.ReadLine()) != null) + { + LanguageData OneLineOfData = new LanguageData(); + string [] temp = line.Split('\t'); + OneLineOfData.Name = temp[0]; + OneLineOfData.Year = int.Parse(temp[1]); + OneLineOfData.Description = temp[2]; + + list.Add(OneLineOfData); + } + + sr.Close(); + return list; + } + } +} diff --git a/Excersise4/Excersise4/Program.cs b/Excersise4/Excersise4/Program.cs new file mode 100644 index 0000000..fb3ac91 --- /dev/null +++ b/Excersise4/Excersise4/Program.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Excersise4 +{ + class Program + { + static void Main() + { + ListLoader myLoader = new ListLoader(); + List languages = new List(); + + languages = myLoader.LoadListFromFile("languageData.txt"); + + Console.Write("Minimum Year: "); + string minimumYear = Console.ReadLine(); + Console.Write("Maximum Year: "); + string maximumYTear = Console.ReadLine(); + + var result = from a in languages + where a.Year > int.Parse(minimumYear) && a.Year < int.Parse(maximumYTear) + select a; + + foreach (var item in result) + { + Console.WriteLine(item.Description); + } + WaitForInput(); + } + + static void WaitForInput() + { + Console.WriteLine("Press Enter..."); + Console.ReadLine(); + } + } +} diff --git a/Excersise4/Excersise4/Properties/AssemblyInfo.cs b/Excersise4/Excersise4/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c7d80c2 --- /dev/null +++ b/Excersise4/Excersise4/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excersise4")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Excersise4")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("49f80c7b-69de-4a04-81f6-d45d560c8e22")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Exercise5/Exercise5.sln b/Exercise5/Exercise5.sln new file mode 100644 index 0000000..d6e357a --- /dev/null +++ b/Exercise5/Exercise5.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise5", "Exercise5\Exercise5.csproj", "{C6760286-A4B9-4319-8BF2-980E111498AD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C6760286-A4B9-4319-8BF2-980E111498AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C6760286-A4B9-4319-8BF2-980E111498AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C6760286-A4B9-4319-8BF2-980E111498AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C6760286-A4B9-4319-8BF2-980E111498AD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Exercise5/Exercise5/App.config b/Exercise5/Exercise5/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Exercise5/Exercise5/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Exercise5/Exercise5/Exercise5.csproj b/Exercise5/Exercise5/Exercise5.csproj new file mode 100644 index 0000000..0598a04 --- /dev/null +++ b/Exercise5/Exercise5/Exercise5.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {C6760286-A4B9-4319-8BF2-980E111498AD} + Exe + Properties + Exercise5 + Exercise5 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Exercise5/Exercise5/Program.cs b/Exercise5/Exercise5/Program.cs new file mode 100644 index 0000000..f457b47 --- /dev/null +++ b/Exercise5/Exercise5/Program.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Exercise5 +{ + class Program + { + public static void Main() + { + var weight = new Weight(); + + weight.SetWeight(WeightUnit.Kilogram, 2.0); + weight.Add(WeightUnit.Pound, 1.0); + weight.Add(WeightUnit.Gram, 450.0); + weight.Add(WeightUnit.Ounce, 1234.0); + + Console.WriteLine("2 Kilo + 1 Pound + 450 Gram + 1234 Ounce is"); + Console.WriteLine("================================================\n"); + + // This line prints 2.453592 + Console.WriteLine("In Kilogram\t" + weight.GetWeight(WeightUnit.Kilogram)); + + // This line prints 5.40924 + Console.WriteLine("In Pounds\t" + weight.GetWeight(WeightUnit.Pound)); + + // This line prints + Console.WriteLine("In Grams\t" + weight.GetWeight(WeightUnit.Gram)); + + // This line prints + Console.WriteLine("In Ounces\t" + weight.GetWeight(WeightUnit.Ounce)); + + WaitForInput(); + + // Dictionary myDictionary; + } + + private static void WaitForInput() + { + Console.WriteLine("\nPress enter..."); + Console.ReadLine(); + } + } +} diff --git a/Exercise5/Exercise5/Properties/AssemblyInfo.cs b/Exercise5/Exercise5/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ce7a04d --- /dev/null +++ b/Exercise5/Exercise5/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Exercise5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Exercise5")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6be72068-8462-46b6-94bb-d88bd795effb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Exercise5/Exercise5/Weight.cs b/Exercise5/Exercise5/Weight.cs new file mode 100644 index 0000000..d2ca24b --- /dev/null +++ b/Exercise5/Exercise5/Weight.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Exercise5 +{ + class Weight + { + private double weight = 0; // Nullable Type + + public void SetWeight(WeightUnit weightUnit, double p) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + weight = p; + break; + case WeightUnit.Pound: + weight = p * 0.45359237; + break; + case WeightUnit.Gram: + weight = p / 1000; + break; + case WeightUnit.Ounce: + weight = p * 0.0283495231; + break; + } + } + + public void Add(WeightUnit weightUnit, double p) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + weight += p; + break; + case WeightUnit.Pound: + weight += p * 0.45359237; + break; + case WeightUnit.Gram: + weight = p / 1000; + break; + case WeightUnit.Ounce: + weight = p * 0.0283495231; + break; + } + } + + public double GetWeight(WeightUnit weightUnit) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + return weight; + break; + case WeightUnit.Pound: + return (weight*2.20462262); + break; + case WeightUnit.Gram: + return (weight * 1000); + break; + case WeightUnit.Ounce: + return (weight * 35.2739619); + break; + default: + throw new NotImplementedException(); + break; + } + } + } +} diff --git a/Exercise5/Exercise5/WeightUnit.cs b/Exercise5/Exercise5/WeightUnit.cs new file mode 100644 index 0000000..ef1e6b1 --- /dev/null +++ b/Exercise5/Exercise5/WeightUnit.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Exercise5 +{ + + public enum WeightUnit : long + { + Kilogram, + Gram, + Pound, + Ounce + } +} diff --git a/Exercise6/Exercise6.sln b/Exercise6/Exercise6.sln new file mode 100644 index 0000000..c29f86f --- /dev/null +++ b/Exercise6/Exercise6.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise6", "Exercise6\Exercise6.csproj", "{6456ED51-C115-41E1-AF2E-7663967825F4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6456ED51-C115-41E1-AF2E-7663967825F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6456ED51-C115-41E1-AF2E-7663967825F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6456ED51-C115-41E1-AF2E-7663967825F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6456ED51-C115-41E1-AF2E-7663967825F4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Exercise6/Exercise6/App.config b/Exercise6/Exercise6/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Exercise6/Exercise6/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Exercise6/Exercise6/CustomStack.cs b/Exercise6/Exercise6/CustomStack.cs new file mode 100644 index 0000000..ed52c7f --- /dev/null +++ b/Exercise6/Exercise6/CustomStack.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Linq; +using System.Text; + +namespace Exercise6 +{ + class CustomStack : IEnumerable + { + private List items = new List(); + + public T Peek() + { + T item = items[0]; + return item; + } + public T Pop() + { + T item = items[0]; + items.RemoveAt(0); + return item; + } + public T Push(T item) + { + items.Insert(0, item); + return item; + } + + private bool isEmpty() + { + if (items.Count == 0) + return true; + else + return false; + } + + public void Add(T item) + { + Push(item); + } + + public IEnumerator GetEnumerator() + { + foreach (var item in items) + { + yield return item; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/Exercise6/Exercise6/Exercise6.csproj b/Exercise6/Exercise6/Exercise6.csproj new file mode 100644 index 0000000..9f3364c --- /dev/null +++ b/Exercise6/Exercise6/Exercise6.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {6456ED51-C115-41E1-AF2E-7663967825F4} + Exe + Properties + Exercise6 + Exercise6 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Exercise6/Exercise6/Program.cs b/Exercise6/Exercise6/Program.cs new file mode 100644 index 0000000..51ff48b --- /dev/null +++ b/Exercise6/Exercise6/Program.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Exercise6 +{ + class Program + { + static void Main(string[] args) + { + /* + var myScienceStack = new CustomStack(); + + myScienceStack.Push("Carl Sagan"); + myScienceStack.Push("Albert Einstein"); + myScienceStack.Push("Stephen Hawking"); + myScienceStack.Push("Neil deGrasse Tyson"); + myScienceStack.Push("Wolfgang Pauli"); + myScienceStack.Push("Edsger Dijkstra"); + myScienceStack.Push("Bjarne Stroustrup"); + myScienceStack.Push("Linus Torvalds"); + */ + + var myScienceStack = new CustomStack () + { + "Carl Sagan", + "Albert Einstein", + "Stephen Hawking", + "Neil deGrasse Tyson", + "Wolfgang Pauli", + "Edsger Dijkstra", + "Bjarne Stroustrup", + "Linus Torvalds" + }; + + show(myScienceStack); + WaitForInput(); + } + + private static void show(CustomStack myScienceStack) + { + foreach (var person in myScienceStack) + { + Console.WriteLine("Person: " + person); + } + ; + } + + + static void WaitForInput() + { + Console.WriteLine("Press Enter..."); + Console.ReadLine(); + } + } +} diff --git a/Exercise6/Exercise6/Properties/AssemblyInfo.cs b/Exercise6/Exercise6/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d0e8693 --- /dev/null +++ b/Exercise6/Exercise6/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Exercise6")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Exercise6")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d59344ce-38f3-482a-81e4-7abcb43eabd0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Exercise8/Exercise8.sln b/Exercise8/Exercise8.sln new file mode 100644 index 0000000..8f03a03 --- /dev/null +++ b/Exercise8/Exercise8.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise8", "Exercise8\Exercise8.csproj", "{A83951A4-9AC1-4697-8F7E-7EBA3410028B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Exercise8/Exercise8/App.config b/Exercise8/Exercise8/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Exercise8/Exercise8/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Exercise8/Exercise8/Exercise8.csproj b/Exercise8/Exercise8/Exercise8.csproj new file mode 100644 index 0000000..dc16da0 --- /dev/null +++ b/Exercise8/Exercise8/Exercise8.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {A83951A4-9AC1-4697-8F7E-7EBA3410028B} + Exe + Properties + Exercise8 + Exercise8 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Exercise8/Exercise8/Program.cs b/Exercise8/Exercise8/Program.cs new file mode 100644 index 0000000..058ba28 --- /dev/null +++ b/Exercise8/Exercise8/Program.cs @@ -0,0 +1,29 @@ +using System; + +namespace Exercise8 +{ + class Program + { + static void Main(string[] args) + { + // Create a new Weight from a double of 2.5 Pounds + double w = 2.5; + var weightFromDouble = w.ConvertToWeight(WeightUnit.Pound); + + // Create a new Weight from a double of 2.5 Pounds + var weightFromString = "15".ConvertToWeight(WeightUnit.Ounce); + + weightFromDouble.PrintMe(WeightUnit.Kilogram); + weightFromString.PrintMe(WeightUnit.Pound); + + WaitForInput(); + } + + private static void WaitForInput() + { + Console.WriteLine("\nPress a key..."); + Console.ReadLine(); + } + + } +} diff --git a/Exercise8/Exercise8/Properties/AssemblyInfo.cs b/Exercise8/Exercise8/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f278bce --- /dev/null +++ b/Exercise8/Exercise8/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Exercise8")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Exercise8")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3a112416-4ffe-4cf8-9977-e7102c114dbf")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Exercise8/Exercise8/Weight.cs b/Exercise8/Exercise8/Weight.cs new file mode 100644 index 0000000..c824bf1 --- /dev/null +++ b/Exercise8/Exercise8/Weight.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Exercise8 +{ + class Weight + { + private double weight = 0; // Nullable Type + + public void SetWeight(WeightUnit weightUnit, double newWeight) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + weight = newWeight; + break; + case WeightUnit.Pound: + weight = newWeight * 0.45359237; + break; + case WeightUnit.Gram: + weight = newWeight / 1000; + break; + case WeightUnit.Ounce: + weight = newWeight * 0.0283495231; + break; + } + } + + public void Add(WeightUnit weightUnit, double p) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + weight += p; + break; + case WeightUnit.Pound: + weight += p * 0.45359237; + break; + case WeightUnit.Gram: + weight = p / 1000; + break; + case WeightUnit.Ounce: + weight = p * 0.0283495231; + break; + } + } + + public double GetWeight(WeightUnit weightUnit) + { + switch (weightUnit) + { + case WeightUnit.Kilogram: + return weight; + break; + case WeightUnit.Pound: + return (weight*2.20462262); + break; + case WeightUnit.Gram: + return (weight * 1000); + break; + case WeightUnit.Ounce: + return (weight * 35.2739619); + break; + default: + throw new NotImplementedException(); + break; + } + } + + public void Add(Weight w) + { + weight += w.GetWeight(WeightUnit.Kilogram); + } + + public void SetWeight(Weight w) + { + SetWeight(WeightUnit.Kilogram, w.GetWeight(WeightUnit.Kilogram)); + } + + public static Weight operator +(Weight leftWeight, Weight rightWeight) + { + Weight sumWeight = new Weight(); + + sumWeight.SetWeight(WeightUnit.Kilogram, leftWeight.GetWeight(WeightUnit.Kilogram) + rightWeight.GetWeight(WeightUnit.Kilogram)); + + return sumWeight; + } + } +} diff --git a/Exercise8/Exercise8/WeightExtensions.cs b/Exercise8/Exercise8/WeightExtensions.cs new file mode 100644 index 0000000..31b58b4 --- /dev/null +++ b/Exercise8/Exercise8/WeightExtensions.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Exercise8 +{ + static class WeightExtensions + { + public static Weight ConvertToWeight(this double input, WeightUnit unit) + { + var w = new Weight(); + + w.SetWeight(unit, input); + + return w; + } + + public static Weight ConvertToWeight(this string input, WeightUnit unit) + { + var w = new Weight(); + + w.SetWeight(unit, Double.Parse(input)); + + return w; + } + + public static void PrintMe(this Weight input, WeightUnit unit) + { + Console.WriteLine("This objects weights " + input.GetWeight(WeightUnit.Kilogram) + " " + unit); + } + } +} diff --git a/Exercise8/Exercise8/WeightUnit.cs b/Exercise8/Exercise8/WeightUnit.cs new file mode 100644 index 0000000..a5b5dc6 --- /dev/null +++ b/Exercise8/Exercise8/WeightUnit.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Exercise8 +{ + + public enum WeightUnit : long + { + Kilogram, + Gram, + Pound, + Ounce + } +} diff --git a/Exercise9A/Exercise9A.sln b/Exercise9A/Exercise9A.sln new file mode 100644 index 0000000..5089e4d --- /dev/null +++ b/Exercise9A/Exercise9A.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise9A", "Exercise9A\Exercise9A.csproj", "{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Exercise9A/Exercise9A/App.config b/Exercise9A/Exercise9A/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Exercise9A/Exercise9A/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Exercise9A/Exercise9A/Calculator.cs b/Exercise9A/Exercise9A/Calculator.cs new file mode 100644 index 0000000..8f1990d --- /dev/null +++ b/Exercise9A/Exercise9A/Calculator.cs @@ -0,0 +1,15 @@ +using System; + +namespace Exercise9A +{ + class Calculator + { + public CalcDelegate CalcLogic { get; set; } + + public void PrintCalculation(double a, double b) + { + double result = CalcLogic(a, b); + Console.WriteLine("Result: " + result); + } + } +} diff --git a/Exercise9A/Exercise9A/Exercise9A.csproj b/Exercise9A/Exercise9A/Exercise9A.csproj new file mode 100644 index 0000000..2fe5cab --- /dev/null +++ b/Exercise9A/Exercise9A/Exercise9A.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {8EE7D0DE-EA39-4754-8A55-FB8DC09535D5} + Exe + Properties + Exercise9A + Exercise9A + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Exercise9A/Exercise9A/Program.cs b/Exercise9A/Exercise9A/Program.cs new file mode 100644 index 0000000..231b170 --- /dev/null +++ b/Exercise9A/Exercise9A/Program.cs @@ -0,0 +1,28 @@ +using System; + +namespace Exercise9A +{ + public delegate double CalcDelegate(double a, double b); + + class Program + { + static void Main(string[] args) + { + var myCalculator = new Calculator(); + //myCalculator.CalcLogic = (a, b) => Math.Pow(a, b); + //myCalculator.CalcLogic = (a, b) => a + b; + myCalculator.CalcLogic = (a, b) => a - b; + myCalculator.PrintCalculation(3, 4); + + + WaitForInput(); + } + + private static void WaitForInput() + { + Console.WriteLine("\nEnter a key..."); + Console.ReadLine(); + } + + } +} diff --git a/Exercise9A/Exercise9A/Properties/AssemblyInfo.cs b/Exercise9A/Exercise9A/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..76dc69e --- /dev/null +++ b/Exercise9A/Exercise9A/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Exercise9A")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Exercise9A")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("913ba60c-7623-436c-8d7e-fdbbdb8b1163")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Exercise9B/Exercise9B.sln b/Exercise9B/Exercise9B.sln new file mode 100644 index 0000000..79bc1f0 --- /dev/null +++ b/Exercise9B/Exercise9B.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise9B", "Exercise9B\Exercise9B.csproj", "{27DD1E20-317D-4C84-9663-D5991EB1F3A0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Exercise9B/Exercise9B/App.config b/Exercise9B/Exercise9B/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Exercise9B/Exercise9B/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Exercise9B/Exercise9B/Exercise9B.csproj b/Exercise9B/Exercise9B/Exercise9B.csproj new file mode 100644 index 0000000..815e106 --- /dev/null +++ b/Exercise9B/Exercise9B/Exercise9B.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {27DD1E20-317D-4C84-9663-D5991EB1F3A0} + Exe + Properties + Exercise9B + Exercise9B + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Exercise9B/Exercise9B/Program.cs b/Exercise9B/Exercise9B/Program.cs new file mode 100644 index 0000000..be19555 --- /dev/null +++ b/Exercise9B/Exercise9B/Program.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Exercise9B +{ + static class Program + { + static void Main(string[] args) + { + var integerList = new List {6, 2, 7, 4, 3, 9, 8, 5, 1}; + Console.WriteLine("\nUn-ordered List"); + PrintList(integerList); + + var orderedList = integerList.OrderMyList(); + Console.WriteLine("\n\nSorted List"); + PrintList(orderedList); + + WaitForInput(); + } + + private static void PrintList(List result) + { + foreach (var num in result) + { + Console.WriteLine(num); + } + } + + + + public static List OrderMyList(this List input) + { + var newList = new List(); + + while (input.Count > 0) + { + int min = input.Min(); + newList.Add(min); + input.RemoveAt(input.IndexOf(input.Min())); + } + + return newList; + } + private static void WaitForInput() + { + Console.WriteLine("\nEnter a key..."); + Console.ReadLine(); + } + + } +} diff --git a/Exercise9B/Exercise9B/Properties/AssemblyInfo.cs b/Exercise9B/Exercise9B/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3aac46d --- /dev/null +++ b/Exercise9B/Exercise9B/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Exercise9B")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Exercise9B")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b70a050a-1558-417d-acd5-8c5fd645f258")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SlideTester/SlideTester.sln b/SlideTester/SlideTester.sln new file mode 100644 index 0000000..c2c9e56 --- /dev/null +++ b/SlideTester/SlideTester.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlideTester", "SlideTester\SlideTester.csproj", "{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SlideTester/SlideTester/App.config b/SlideTester/SlideTester/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/SlideTester/SlideTester/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SlideTester/SlideTester/Program.cs b/SlideTester/SlideTester/Program.cs new file mode 100644 index 0000000..eff289f --- /dev/null +++ b/SlideTester/SlideTester/Program.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SlideTester +{ + class Program + { + enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri }; + + static void Main(string[] args) + { + string Namnet = "Christian"; + string Name = null; + Console.WriteLine(Name ?? "No name set"); + + int x = 42; + Console.WriteLine(x.Double()); + + WaitForInput(); + } + + static void WaitForInput() + { + Console.WriteLine("\nPress a key..."); + Console.ReadLine(); + } + } + + static class Extension + { + public static int Double(this int input) + { + return input*2; + } + } +} diff --git a/SlideTester/SlideTester/Properties/AssemblyInfo.cs b/SlideTester/SlideTester/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0949032 --- /dev/null +++ b/SlideTester/SlideTester/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SlideTester")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SlideTester")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a34a1956-9ec3-4574-8714-c30b3ef94bd1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SlideTester/SlideTester/SlideTester.csproj b/SlideTester/SlideTester/SlideTester.csproj new file mode 100644 index 0000000..8a3fdf0 --- /dev/null +++ b/SlideTester/SlideTester/SlideTester.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {B1343E62-CD0A-4C9B-B22E-29C8D88AECCE} + Exe + Properties + SlideTester + SlideTester + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Structs/ConsoleSlask.sln b/Structs/ConsoleSlask.sln new file mode 100644 index 0000000..321358d --- /dev/null +++ b/Structs/ConsoleSlask.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSlask", "ConsoleSlask\ConsoleSlask.csproj", "{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Structs/ConsoleSlask/App.config b/Structs/ConsoleSlask/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Structs/ConsoleSlask/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Structs/ConsoleSlask/ConsoleSlask.csproj b/Structs/ConsoleSlask/ConsoleSlask.csproj new file mode 100644 index 0000000..ffa6d15 --- /dev/null +++ b/Structs/ConsoleSlask/ConsoleSlask.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {AD447D40-3ED5-466E-BE8C-8A6004B7DE7D} + Exe + Properties + ConsoleSlask + ConsoleSlask + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Structs/ConsoleSlask/Program.cs b/Structs/ConsoleSlask/Program.cs new file mode 100644 index 0000000..ec19af3 --- /dev/null +++ b/Structs/ConsoleSlask/Program.cs @@ -0,0 +1,43 @@ +using System; + +namespace ConsoleSlask +{ + class Program + { + public struct Person + { + public string FirstName { get; set; } + public string LastName { get; set; } + public int YearOfBirth; + + // En låtsas-konstruktor för en Struct + public Person(string firstName, string lastName, int yearOfBirth) : this() + { + FirstName = firstName; + LastName = lastName; + YearOfBirth = yearOfBirth; + } + } + + static void WaitForInput() + { + Console.WriteLine("Press Enter..."); + Console.ReadLine(); + } + + private static void PrintPerson(Person p) + { + Console.WriteLine("FirstName: " + p.FirstName); + Console.WriteLine("LastName: " + p.LastName); + Console.WriteLine("YearOfBirth: " + p.YearOfBirth); + WaitForInput(); + } + + static void Main() + { + Console.WriteLine("Hello World!"); + Person p = new Person(firstName: "Christian", lastName: "Ohlsson", yearOfBirth: 1973); + PrintPerson(p); + } + } +} diff --git a/Structs/ConsoleSlask/Properties/AssemblyInfo.cs b/Structs/ConsoleSlask/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a788583 --- /dev/null +++ b/Structs/ConsoleSlask/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleSlask")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleSlask")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("75b54cd6-0425-4e5a-a948-95ccdab69382")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]