diff --git a/Module4-Assignments/Module4-Assignments.sln b/Module4-Assignments/Module4-Assignments.sln new file mode 100644 index 0000000..506ba54 --- /dev/null +++ b/Module4-Assignments/Module4-Assignments.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32414.318 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Task1", "Task1\Task1.csproj", "{9971B944-1F40-4588-A867-17D2EE4F6E51}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Task2", "Task2\Task2.csproj", "{0C50AA3F-F49E-403A-A3E2-821336B52E9D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9971B944-1F40-4588-A867-17D2EE4F6E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9971B944-1F40-4588-A867-17D2EE4F6E51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9971B944-1F40-4588-A867-17D2EE4F6E51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9971B944-1F40-4588-A867-17D2EE4F6E51}.Release|Any CPU.Build.0 = Release|Any CPU + {0C50AA3F-F49E-403A-A3E2-821336B52E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C50AA3F-F49E-403A-A3E2-821336B52E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C50AA3F-F49E-403A-A3E2-821336B52E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C50AA3F-F49E-403A-A3E2-821336B52E9D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EDBB0A61-25C0-4EA2-A152-334D77C5F621} + EndGlobalSection +EndGlobal diff --git a/Module4-Assignments/Task1/App.config b/Module4-Assignments/Task1/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Module4-Assignments/Task1/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Module4-Assignments/Task1/Properties/AssemblyInfo.cs b/Module4-Assignments/Task1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7ae22b2 --- /dev/null +++ b/Module4-Assignments/Task1/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("Task1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Task1")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[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("9971b944-1f40-4588-a867-17d2ee4f6e51")] + +// 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/Module4-Assignments/Task1/Task1.cs b/Module4-Assignments/Task1/Task1.cs new file mode 100644 index 0000000..8b7e91c --- /dev/null +++ b/Module4-Assignments/Task1/Task1.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Task1 +{ + internal class Task1 + { + static void Main(string[] args) + { + var shape = new Shape(1, 2); + Console.WriteLine(shape.Display()); + + var circle = new Circle(2, 3, 4); + Console.WriteLine(circle.Display()); + + var cylinder = new Cylinder(3, 4, 5, 6); + Console.WriteLine(cylinder.Display()); + + Console.WriteLine("press any key to exit"); + Console.ReadKey(); + } + } +} + +class Shape +{ + protected int _x; + protected int _y; + + public Shape(int x, int y) + { + _x = x; + _y = y; + } + + public int X + { + get { return _x; } + } + + public int Y + { + get { return _y; } + } + + public virtual string Display() + { + return $"X: {_x}, Y: {_y}"; + } +}; + +class Circle : Shape +{ + protected int _r; + public Circle(int x, int y, int r) + : base(x, y) + { + _r = r; + } + + public virtual double Area + { + get => Math.PI * Math.Pow(_r, 2); + } + + public override string Display() + { + return base.Display() + $", R: {Area}"; + } +}; + +class Cylinder : Circle +{ + protected int _h; + public Cylinder(int x, int y, int r, int h) : base(x, y, r) + { + _h = h; + } + + public override double Area + { + get => (2 * Math.PI * Math.Pow(_r, 2)) + (2 * Math.PI * _r * _h); + } + + public virtual double Volume + { + get => Math.PI * Math.Pow(_r, 2) * _h; + } + + public override string Display() + { + return base.Display() + $", V: {Volume}"; + } +} \ No newline at end of file diff --git a/Module4-Assignments/Task1/Task1.csproj b/Module4-Assignments/Task1/Task1.csproj new file mode 100644 index 0000000..746bee0 --- /dev/null +++ b/Module4-Assignments/Task1/Task1.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {9971B944-1F40-4588-A867-17D2EE4F6E51} + Exe + Task1 + Task1 + v4.7.2 + 512 + true + true + + + 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/Module4-Assignments/Task1/bin/Debug/Task1.exe b/Module4-Assignments/Task1/bin/Debug/Task1.exe new file mode 100644 index 0000000..493115b Binary files /dev/null and b/Module4-Assignments/Task1/bin/Debug/Task1.exe differ diff --git a/Module4-Assignments/Task1/bin/Debug/Task1.exe.config b/Module4-Assignments/Task1/bin/Debug/Task1.exe.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Module4-Assignments/Task1/bin/Debug/Task1.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Module4-Assignments/Task1/bin/Debug/Task1.pdb b/Module4-Assignments/Task1/bin/Debug/Task1.pdb new file mode 100644 index 0000000..34e0547 Binary files /dev/null and b/Module4-Assignments/Task1/bin/Debug/Task1.pdb differ diff --git a/Module4-Assignments/Task1/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/Module4-Assignments/Task1/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/Module4-Assignments/Task1/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/Module4-Assignments/Task1/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Module4-Assignments/Task1/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..c5634ba Binary files /dev/null and b/Module4-Assignments/Task1/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Module4-Assignments/Task1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Module4-Assignments/Task1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..9f72af4 Binary files /dev/null and b/Module4-Assignments/Task1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Module4-Assignments/Task1/obj/Debug/Task1.csproj.AssemblyReference.cache b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.AssemblyReference.cache new file mode 100644 index 0000000..126ed02 Binary files /dev/null and b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.AssemblyReference.cache differ diff --git a/Module4-Assignments/Task1/obj/Debug/Task1.csproj.CoreCompileInputs.cache b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..17e69e5 --- /dev/null +++ b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +c30be9dfcf782c1ea85dc8ac3ce30d3f96bc76c7 diff --git a/Module4-Assignments/Task1/obj/Debug/Task1.csproj.FileListAbsolute.txt b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..da65df8 --- /dev/null +++ b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\bin\Debug\Task1.exe.config +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\bin\Debug\Task1.exe +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\bin\Debug\Task1.pdb +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\obj\Debug\Task1.csproj.AssemblyReference.cache +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\obj\Debug\Task1.csproj.SuggestedBindingRedirects.cache +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\obj\Debug\Task1.csproj.CoreCompileInputs.cache +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\obj\Debug\Task1.exe +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task1\obj\Debug\Task1.pdb diff --git a/Module4-Assignments/Task1/obj/Debug/Task1.csproj.SuggestedBindingRedirects.cache b/Module4-Assignments/Task1/obj/Debug/Task1.csproj.SuggestedBindingRedirects.cache new file mode 100644 index 0000000..e69de29 diff --git a/Module4-Assignments/Task1/obj/Debug/Task1.exe b/Module4-Assignments/Task1/obj/Debug/Task1.exe new file mode 100644 index 0000000..493115b Binary files /dev/null and b/Module4-Assignments/Task1/obj/Debug/Task1.exe differ diff --git a/Module4-Assignments/Task1/obj/Debug/Task1.pdb b/Module4-Assignments/Task1/obj/Debug/Task1.pdb new file mode 100644 index 0000000..34e0547 Binary files /dev/null and b/Module4-Assignments/Task1/obj/Debug/Task1.pdb differ diff --git a/Module4-Assignments/Task2/App.config b/Module4-Assignments/Task2/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Module4-Assignments/Task2/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Module4-Assignments/Task2/Properties/AssemblyInfo.cs b/Module4-Assignments/Task2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..012e98c --- /dev/null +++ b/Module4-Assignments/Task2/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("Task2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Task2")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[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("0c50aa3f-f49e-403a-a3e2-821336b52e9d")] + +// 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/Module4-Assignments/Task2/Task2.cs b/Module4-Assignments/Task2/Task2.cs new file mode 100644 index 0000000..9a966a4 --- /dev/null +++ b/Module4-Assignments/Task2/Task2.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Task2 +{ + internal class Task2 + { + static void Main(string[] args) + { + var sten = new SalariedEmployee("Sten", "Hard", "73403fjh91", 23.5); + Console.WriteLine($"Sten has a social security number of {sten.SSN} and a weekly salary of {sten.WeeklySalary} of some random currency"); + + var bjorn = new HourlyEmployee("Bjorn", "Rik", "fsjdklfd89", 37, 13); + Console.WriteLine($"Bjorns last name is {bjorn.LastName} and he earned {bjorn.Earning()} this week"); + + Console.WriteLine("Press any key to exit"); + Console.ReadKey(); + } + } +} + +abstract class Employee +{ + private string _firstName, _lastName, _ssn; + + public string FirstName { get => _firstName; } + public string LastName { get => _lastName; } + public string SSN { get => _ssn; } + + public Employee(string firstName, string lastName, string ssn) + { + _firstName = firstName; + _lastName = lastName; + _ssn = ssn; + } + + public override string ToString() + { + return FirstName + " " + LastName + " " + SSN; + } + + public abstract double Earning(); +}; + +class SalariedEmployee : Employee +{ + private double _weeklySalary; + + public double WeeklySalary { get => _weeklySalary; } + public SalariedEmployee(string firstName, string lastName, string ssn, double weeklySalary) + : base(firstName, lastName, ssn) + { + _weeklySalary = weeklySalary; + } + + public override string ToString() + { + return base.ToString() + "\n" + $"Weekly Salary: {WeeklySalary}"; + } + public override double Earning() + { + return _weeklySalary; + } +} + +class HourlyEmployee : Employee +{ + private int _weeklyWorkedHours; + private double _hourlyWage; + + public HourlyEmployee(string firstName, + string lastName, + string ssn, + int weeklyWorkedHours, + double hourlyWage) + : base(firstName, lastName, ssn) + { + _weeklyWorkedHours = weeklyWorkedHours; + _hourlyWage = hourlyWage; + } + + public int WeeklyWorkedHours { get => _weeklyWorkedHours; } + + public double HourlyWage { get => _hourlyWage; } + + public override string ToString() + { + return base.ToString() + + "\n" + $"Weekly worked hours: {WeeklyWorkedHours}" + + "\n" + $"Hourly Wage: {HourlyWage}"; + } + + public override double Earning() + { + return (double)_weeklyWorkedHours * _hourlyWage; + } +} \ No newline at end of file diff --git a/Module4-Assignments/Task2/Task2.csproj b/Module4-Assignments/Task2/Task2.csproj new file mode 100644 index 0000000..ac59e24 --- /dev/null +++ b/Module4-Assignments/Task2/Task2.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {0C50AA3F-F49E-403A-A3E2-821336B52E9D} + Exe + Task2 + Task2 + v4.7.2 + 512 + true + true + + + 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/Module4-Assignments/Task2/bin/Debug/Task2.exe b/Module4-Assignments/Task2/bin/Debug/Task2.exe new file mode 100644 index 0000000..f275cb9 Binary files /dev/null and b/Module4-Assignments/Task2/bin/Debug/Task2.exe differ diff --git a/Module4-Assignments/Task2/bin/Debug/Task2.exe.config b/Module4-Assignments/Task2/bin/Debug/Task2.exe.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Module4-Assignments/Task2/bin/Debug/Task2.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Module4-Assignments/Task2/bin/Debug/Task2.pdb b/Module4-Assignments/Task2/bin/Debug/Task2.pdb new file mode 100644 index 0000000..88d3f93 Binary files /dev/null and b/Module4-Assignments/Task2/bin/Debug/Task2.pdb differ diff --git a/Module4-Assignments/Task2/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/Module4-Assignments/Task2/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/Module4-Assignments/Task2/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/Module4-Assignments/Task2/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/Module4-Assignments/Task2/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..c5634ba Binary files /dev/null and b/Module4-Assignments/Task2/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Module4-Assignments/Task2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Module4-Assignments/Task2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..753581d Binary files /dev/null and b/Module4-Assignments/Task2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Module4-Assignments/Task2/obj/Debug/Task2.csproj.AssemblyReference.cache b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.AssemblyReference.cache new file mode 100644 index 0000000..126ed02 Binary files /dev/null and b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.AssemblyReference.cache differ diff --git a/Module4-Assignments/Task2/obj/Debug/Task2.csproj.CoreCompileInputs.cache b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..d4295be --- /dev/null +++ b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +7ce87abeb702b8d44db011cb3c28101c90a5fb6e diff --git a/Module4-Assignments/Task2/obj/Debug/Task2.csproj.FileListAbsolute.txt b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..22a5a1a --- /dev/null +++ b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\bin\Debug\Task2.exe.config +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\bin\Debug\Task2.exe +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\bin\Debug\Task2.pdb +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\obj\Debug\Task2.csproj.AssemblyReference.cache +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\obj\Debug\Task2.csproj.SuggestedBindingRedirects.cache +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\obj\Debug\Task2.csproj.CoreCompileInputs.cache +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\obj\Debug\Task2.exe +D:\Git\Bashir C-sharp assignments\Module4-Assignments\Task2\obj\Debug\Task2.pdb diff --git a/Module4-Assignments/Task2/obj/Debug/Task2.csproj.SuggestedBindingRedirects.cache b/Module4-Assignments/Task2/obj/Debug/Task2.csproj.SuggestedBindingRedirects.cache new file mode 100644 index 0000000..e69de29 diff --git a/Module4-Assignments/Task2/obj/Debug/Task2.exe b/Module4-Assignments/Task2/obj/Debug/Task2.exe new file mode 100644 index 0000000..f275cb9 Binary files /dev/null and b/Module4-Assignments/Task2/obj/Debug/Task2.exe differ diff --git a/Module4-Assignments/Task2/obj/Debug/Task2.pdb b/Module4-Assignments/Task2/obj/Debug/Task2.pdb new file mode 100644 index 0000000..88d3f93 Binary files /dev/null and b/Module4-Assignments/Task2/obj/Debug/Task2.pdb differ