├── .gitattributes ├── .gitignore ├── 0-Start-Here └── README.md ├── README.md ├── Tools └── StudentsRandomizer │ ├── StudentsRandomizer.sln │ └── StudentsRandomizer │ ├── App.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ └── StudentsRandomizer.csproj ├── partners ├── Nemetschek.png ├── SAP_Labs_Bulgaria.png └── SITEGROUND.png ├── week01 ├── 01-Warmups │ └── README.md ├── 02-LanguageConstructs │ └── README.md ├── 03-MoreProblems │ └── README.md └── README.md ├── week02 ├── 01-Methods │ └── README.md ├── 02 - Methods-Part Two │ └── README.md ├── 03-SourceControl │ └── README.md └── README.md ├── week03 ├── 01-IntroToOOP │ ├── README.md │ └── solutions │ │ ├── Fractions │ │ ├── Fractions.sln │ │ ├── Fractions │ │ │ ├── Fraction.cs │ │ │ ├── Fractions.csproj │ │ │ └── Properties │ │ │ │ └── AssemblyInfo.cs │ │ └── FractionsApplication │ │ │ ├── App.config │ │ │ ├── FractionsApplication.csproj │ │ │ ├── Program.cs │ │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ │ └── Vector │ │ ├── Vector.sln │ │ ├── Vector │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Vector.cs │ │ └── Vector.csproj │ │ └── VectorsApplication │ │ ├── App.config │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── VectorsApplication.csproj ├── 02-MoreOOP │ └── README.md ├── 03-AgainOOP │ ├── BouncingBallProject │ │ ├── BouncingBallProject.sln │ │ └── BouncingBallProject │ │ │ ├── BouncingBallProject.csproj │ │ │ ├── Form1.Designer.cs │ │ │ ├── Form1.cs │ │ │ ├── Form1.resx │ │ │ ├── Program.cs │ │ │ └── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ ├── Resources.resx │ │ │ ├── Settings.Designer.cs │ │ │ └── Settings.settings │ ├── README.md │ └── solutions │ │ └── ShopInventory │ │ ├── ShopInventory.sln │ │ ├── ShopInventory │ │ ├── CountryVatTax.cs │ │ ├── NotAvailableInInventoryException.cs │ │ ├── NotSupportedCountryException.cs │ │ ├── Order.cs │ │ ├── Product.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── ShopInventory.cs │ │ ├── ShopInventory.csproj │ │ └── VatTaxCalculator.cs │ │ └── ShopInventoryApplication │ │ ├── App.config │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── ShopInventoryApplication.csproj └── README.md ├── week04 ├── 01-GenericType │ └── README.md ├── 02-More-Generics-And-Collections │ └── README.md └── README.md ├── week05 ├── 01-SortingAndSearching │ └── README.md ├── 02-Inheritance │ ├── README.md │ └── Shapes │ │ ├── Shapes.sln │ │ ├── Shapes │ │ ├── IDisplayable.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Rectangle.cs │ │ └── Shapes.csproj │ │ └── ShapesDesktopApplication │ │ ├── App.config │ │ ├── MainForm.Designer.cs │ │ ├── MainForm.cs │ │ ├── MainForm.resx │ │ ├── Program.cs │ │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ │ └── ShapesDesktopApplication.csproj ├── 03-OOPExercises │ └── Readme.md └── README.md ├── week06 ├── 01 - Exceptions │ └── README.md ├── 02 - Delegates │ └── README.md ├── 03---Static-Partial-Anonymous-Types │ └── Readme.md └── README.md ├── week07 ├── 01-Linq-Basics │ └── Readme.md ├── 02 - Introduction to SQL │ └── Readme.md └── Readme.md ├── week08 ├── 01-FilesAndStreams │ └── README.md ├── 02-PandaSocialNetwork │ ├── README.md │ ├── StudentGroups.md │ └── solutions │ │ └── BFS │ │ ├── BFS.sln │ │ ├── BFSApplication │ │ ├── App.config │ │ ├── BFSApplication.csproj │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ │ └── BFSLibrary │ │ ├── BFS.cs │ │ ├── BFSLibrary.csproj │ │ ├── GraphNode.cs │ │ └── Properties │ │ └── AssemblyInfo.cs ├── 03-SQL-DatabaseDesign │ └── Readme.md └── README.md ├── week09 ├── 02-ADO.NET │ └── README.md └── README.md ├── week10 ├── 01 - Books With LinqToSQL │ └── README.md ├── 02 - Ticket System │ └── README.md └── README.md ├── week11 ├── 01 - Windows Forms │ └── README.md ├── 02 - WPF │ └── README.md ├── 03 - Train System App │ └── README.md └── README.md ├── week12 ├── 02 - MVVM │ ├── Northwind.bak │ └── NorthwindMVVMSample │ │ ├── App.config │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── DataAccess.cs │ │ ├── Employee.cs │ │ ├── EmployeesWindow.xaml │ │ ├── EmployeesWindow.xaml.cs │ │ ├── NorhtwindModel.Context.cs │ │ ├── NorhtwindModel.Context.tt │ │ ├── NorhtwindModel.Designer.cs │ │ ├── NorhtwindModel.cs │ │ ├── NorhtwindModel.edmx │ │ ├── NorhtwindModel.edmx.diagram │ │ ├── NorhtwindModel.tt │ │ ├── NorthwindMVVMSample.csproj │ │ ├── Order.cs │ │ ├── Order_Detail.cs │ │ ├── OrdersWindow.xaml │ │ ├── OrdersWindow.xaml.cs │ │ ├── Product.cs │ │ ├── ProductsWindow.xaml │ │ ├── ProductsWindow.xaml.cs │ │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ │ ├── StartupWindow.xaml │ │ ├── StartupWindow.xaml.cs │ │ └── packages.config ├── 03-WebForms │ └── README.md └── README.md ├── week13 ├── 01-MVC │ └── Readme.md ├── 02-MVCTricks │ ├── MVCExample.7z │ └── README.md └── Readme.md ├── week14 ├── 01 - DFS & BFS │ ├── App.config │ ├── PandaSocialNetwork.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs └── README.md ├── week15 ├── 01-HighQualityCode │ └── README.md ├── 03-Threads │ ├── Demos │ │ ├── Tasks │ │ │ └── WindowsFormsApplication7 │ │ │ │ ├── WindowsFormsApplication7.sln │ │ │ │ └── WindowsFormsApplication7 │ │ │ │ ├── App.config │ │ │ │ ├── Form1.Designer.cs │ │ │ │ ├── Form1.cs │ │ │ │ ├── Form1.resx │ │ │ │ ├── Program.cs │ │ │ │ ├── Properties │ │ │ │ ├── AssemblyInfo.cs │ │ │ │ ├── Resources.Designer.cs │ │ │ │ ├── Resources.resx │ │ │ │ ├── Settings.Designer.cs │ │ │ │ └── Settings.settings │ │ │ │ └── WindowsFormsApplication7.csproj │ │ └── Threads │ │ │ └── WindowsFormsApplication6 │ │ │ ├── WindowsFormsApplication6.sln │ │ │ └── WindowsFormsApplication6 │ │ │ ├── App.config │ │ │ ├── Form1.Designer.cs │ │ │ ├── Form1.cs │ │ │ ├── Form1.resx │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ ├── Resources.resx │ │ │ ├── Settings.Designer.cs │ │ │ └── Settings.settings │ │ │ └── WindowsFormsApplication6.csproj │ └── README.md ├── Code.Complete.2nd.Edition.2004.chm └── README.md └── week16 ├── 01-Reflection └── README.md └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /0-Start-Here/README.md: -------------------------------------------------------------------------------- 1 | # Course Starting Pack 2 | 3 | In order to be prepared for the course & start solving problems from day 1, you should: 4 | 5 | * Download and install [Visual Studio 2015 Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx) (the installation may take several hours) 6 | * Take a look at the following tutorials: 7 | * [Visual Studio C# Tutorial for Beginners](https://www.youtube.com/watch?v=UGQX97XNF-A) 8 | * [C# - Program Structure](http://www.tutorialspoint.com/csharp/csharp_program_structure.htm), [C# - Basic Syntax](http://www.tutorialspoint.com/csharp/csharp_basic_syntax.htm) 9 | * [Edx online course by microsoft for beggining c#](https://courses.edx.org/courses/course-v1:Microsoft+DEV204x+1T2016/info) 10 | * [Microsoft Virtual Academy - A lot of online tutorials](https://mva.microsoft.com/) 11 | * If you come from Java or C++, you may read the following articles: 12 | * [A 15 Minute Intro to C# for Java Developers](http://www.techhui.com/profiles/blogs/a-15-minute-intro-to-c-for), [Java and C# Comparison](http://www.harding.edu/fmccown/java_csharp_comparison.html) 13 | * [10 Things C++ Developers Learning C# Should Know](http://geekswithblogs.net/BlackRabbitCoder/archive/2010/08/12/10-things-c-developers-learning-c-should-know.aspx) 14 | * Some good books on C# and .Net net 15 | * [Pro C# 5 and the .Net 4.5 Framework](http://www.apress.com/9781430242338) 16 | * [CLR via C#](http://www.amazon.com/CLR-via-Edition-Developer-Reference/dp/0735667454) -------------------------------------------------------------------------------- /Tools/StudentsRandomizer/StudentsRandomizer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsRandomizer", "StudentsRandomizer\StudentsRandomizer.csproj", "{3293F7B7-9ECB-4D33-A0B7-8FF2FA56734E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3293F7B7-9ECB-4D33-A0B7-8FF2FA56734E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3293F7B7-9ECB-4D33-A0B7-8FF2FA56734E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3293F7B7-9ECB-4D33-A0B7-8FF2FA56734E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3293F7B7-9ECB-4D33-A0B7-8FF2FA56734E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tools/StudentsRandomizer/StudentsRandomizer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Tools/StudentsRandomizer/StudentsRandomizer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace StudentsRandomizer 10 | { 11 | class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | var groupByCount = int.Parse(ConfigurationManager.AppSettings["GroupByCount"]); 16 | var sourceFile = ConfigurationManager.AppSettings["SourceFile"]; 17 | var targetFile = ConfigurationManager.AppSettings["TargetFile"]; 18 | 19 | var students = GetStudents(sourceFile); 20 | Shuffle(students); 21 | var groups = Group(students, groupByCount); 22 | WriteGroups(targetFile, groups); 23 | } 24 | 25 | private static List GetStudents(string fileName) 26 | { 27 | var res = new List(); 28 | using (var reader = new StreamReader(fileName)) 29 | { 30 | string line = null; 31 | while ((line = reader.ReadLine()) != null) 32 | { 33 | res.Add(line); 34 | } 35 | } 36 | 37 | return res; 38 | } 39 | 40 | private static void WriteGroups(string fileName, List> groups) 41 | { 42 | using (var writer = new StreamWriter(fileName)) 43 | { 44 | foreach(var group in groups) 45 | { 46 | var line = string.Join(", ", group); 47 | writer.WriteLine(line); 48 | } 49 | } 50 | } 51 | 52 | private static List> Group(List list, int count) 53 | { 54 | var res = new List>(); 55 | for (int i = 0; i < list.Count; i += count) 56 | { 57 | var group = new List(); 58 | for (int j = i; j < Math.Min(i + count, list.Count); j++) 59 | { 60 | group.Add(list[j]); 61 | } 62 | res.Add(group); 63 | } 64 | 65 | return res; 66 | } 67 | 68 | private static void Shuffle(List list) 69 | { 70 | int n = list.Count; 71 | Random rnd = new Random(); 72 | while (n > 1) 73 | { 74 | int k = (rnd.Next(0, n) % n); 75 | n--; 76 | T value = list[k]; 77 | list[k] = list[n]; 78 | list[n] = value; 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Tools/StudentsRandomizer/StudentsRandomizer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("StudentsRandomizer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("StudentsRandomizer")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3293f7b7-9ecb-4d33-a0b7-8ff2fa56734e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Tools/StudentsRandomizer/StudentsRandomizer/StudentsRandomizer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3293F7B7-9ECB-4D33-A0B7-8FF2FA56734E} 8 | Exe 9 | Properties 10 | StudentsRandomizer 11 | StudentsRandomizer 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | -------------------------------------------------------------------------------- /partners/Nemetschek.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackBulgaria/Programming101-CSharp/bda6a6630cee3ace6deb98f1436990a091a0f08d/partners/Nemetschek.png -------------------------------------------------------------------------------- /partners/SAP_Labs_Bulgaria.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackBulgaria/Programming101-CSharp/bda6a6630cee3ace6deb98f1436990a091a0f08d/partners/SAP_Labs_Bulgaria.png -------------------------------------------------------------------------------- /partners/SITEGROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackBulgaria/Programming101-CSharp/bda6a6630cee3ace6deb98f1436990a091a0f08d/partners/SITEGROUND.png -------------------------------------------------------------------------------- /week01/02-LanguageConstructs/README.md: -------------------------------------------------------------------------------- 1 | # Problems to get you familiar with the most common language constructs 2 | 3 | These problems will require using more specific language constructs. 4 | 5 | ## Number->List and List->Number 6 | 7 | Implement the two functions: 8 | 9 | * `List NumberToList(int n)` which takes an integer and returns a list 10 | of its digits 11 | * `int ListToNumber(string digits)` which takes a list of digits and returns 12 | the number from those digits 13 | 14 | ## Increasing and Decreasing Sequences 15 | 16 | Implement the following functions: 17 | 18 | * `bool IsIncreasing(int[] sequence)` which returns true if for every two 19 | consecutive elements `a` and `b`, `a < b` holds. 20 | * `bool IsDecreasing(int[] sequence)` which returns true if for every two 21 | consecutive elements `a` and `b`, `a > b` holds. 22 | 23 | ## Extreme elements in a list 24 | 25 | Implement the following functions: 26 | 27 | * `int Min(int[] items)` - returns the mininum element in `items` 28 | * `int Max(int[] items)` - returns the maximum element in `items` 29 | * `int NthMin(int n, int[] items)` - returns the `n`th minimum element in 30 | `items` 31 | * `int NthMax(int n, int[] items)` - returns the `n`th maximum element in 32 | `items` 33 | 34 | ## Reverse a String 35 | 36 | Implement a function which takes a string and returns the same in 37 | a reversed order. 38 | 39 | `string ReverseMe(string original)` 40 | 41 | ## Reverse each word in a sentence 42 | 43 | Implement a function which takes a string and returns a string 44 | which has the same words but each word is in a reverse order. 45 | 46 | `string ReverseEveryWord(string sentence)` 47 | 48 | ## Copy every character K times 49 | 50 | `string CopyEveryChar(string input, int k)` 51 | 52 | Example: `CopyEveryChar("tldr", 3) => "tttllldddrrr"` 53 | 54 | ## Decode an URL 55 | 56 | Write a function which decodes a given URL following these rules: 57 | 58 | %20=>' ' 59 | %3A=>':' 60 | %3D=>'?' 61 | %2F=>'/' 62 | 63 | Input 'kitten%20pic.jpg' 64 | Output 'kitten pic.jpg' 65 | 66 | `string DecodeUrl(string input)` 67 | 68 | ## Is String A an anagram of String B? 69 | `bool Anagram(string A, string B)` 70 | See http://en.wikipedia.org/wiki/Anagram 71 | 72 | No HashMaps, hashSets, or such stuff allowed : ) 73 | 74 | ## Is an anagram of String A a SUBSEQUENCE in B? 75 | 76 | Return whether an anagram of String A can be found in String B. 77 | 78 | `bool HasAnagramOf(string A,string B)` -------------------------------------------------------------------------------- /week01/README.md: -------------------------------------------------------------------------------- 1 | # Week01 - Introduction to C# # 2 | 3 | During the first week you'll get acquainted with the Visual Studio development environment and the basic C# syntax. 4 | 5 | ## Introduction 6 | 7 | * [Course Starting Pack](https://github.com/HackBulgaria/Programming101-CSharp/blob/master/0-Start-Here/README.md) 8 | * Naming conventions in C# - [Capitalization Conventions](https://msdn.microsoft.com/en-us/library/ms229043%28v=vs.110%29.aspx) 9 | * Most important naming convention - class, method and property names start with a capital letter and use PascalCase, e.g. `class HackNumber{...}`, `public void GetNumberOfDigits()`, `public int MaxValue{get; set;}` 10 | * [Debugging in Visual Studio](https://www.youtube.com/watch?v=k1EQndVmlOc) 11 | * [C# - Program Structure](http://www.tutorialspoint.com/csharp/csharp_program_structure.htm), [C# - Basic Syntax](http://www.tutorialspoint.com/csharp/csharp_basic_syntax.htm) - check this out for the typical layout of a .cs file and a C# class 12 | 13 | ## C# Reference Introduction 14 | 15 | * Basic C# constructs 16 | * [C# Operators](https://msdn.microsoft.com/en-us/library/6a71f45d.aspx) 17 | * [Branching (if-else, switch)](https://msdn.microsoft.com/en-us/library/s3xe34ex%28v=vs.90%29.aspx), [Loops (for, foreach, do-while)](https://msdn.microsoft.com/en-us/library/f0e10e56%28v=vs.90%29.aspx) 18 | * .Net data types 19 | * [Data Types](https://msdn.microsoft.com/en-us/library/ms228360%28v=vs.90%29.aspx) - builtin data types, enumerations, strings, casting, value vs reference types 20 | * [Strings](https://msdn.microsoft.com/en-us/library/ms228362.aspx) - strings, formatting strings, basic string operations, string immutability and StringBuilder class 21 | * Conversions - [int.Parse() (and the like)](https://msdn.microsoft.com/en-us/library/b3h1hf19.aspx), [Convert class](https://msdn.microsoft.com/en-us/library/system.convert.aspx), [ToString() builtin method](https://msdn.microsoft.com/en-us/library/system.object.tostring%28v=vs.110%29.aspx) 22 | * .Net collections 23 | * [Arrays](http://www.tutorialspoint.com/csharp/csharp_arrays.htm), [Multidimensional Arrays](http://www.tutorialspoint.com/csharp/csharp_multi_dimensional_arrays.htm), [Jagged Arrays](http://www.tutorialspoint.com/csharp/csharp_jagged_arrays.htm) 24 | * [.Net Collections](http://www.growingwiththeweb.com/2013/02/what-data-structure-net-collections-use.html) - the most commonly used are List, Dictionary 25 | 26 | ## More debugging techniques and some useful cmd commands 27 | 28 | * [Visual Studio debugging tutorial](http://www.codeproject.com/Articles/79508/Mastering-Debugging-in-Visual-Studio-A-Beginn) 29 | * [Navigating in Command Prompt](http://www.pcstats.com/articleview.cfm?articleid=1723&page=3) 30 | * [Input redirection in Command Prompt](https://technet.microsoft.com/en-us/library/bb490982.aspx) 31 | * [Comparing files in Command Prompt](http://ss64.com/nt/fc.html) 32 | * [Working with bitmaps in C#](https://msdn.microsoft.com/en-us/library/system.drawing.bitmap%28v=vs.110%29.aspx) 33 | -------------------------------------------------------------------------------- /week02/01-Methods/README.md: -------------------------------------------------------------------------------- 1 | # Problems which involve writing methods in C# # 2 | 3 | ## Reverse a string 4 | 5 | Write a method which takes a List as an argument 6 | and reverses it internally. 7 | 8 | `void ReverseList(List list)` 9 | 10 | The reversed result should be stored inside the same list instance. 11 | 12 | ## Inflate a rectangle 13 | 14 | Write a method which takes a rectangle as an argument and 15 | inflates it with the specified size in all directions. 16 | This means that if you get a rectangle (x:0,y:0,w:10,h:10) and inflate 17 | it with a size of (2,2), the resulting rectangle should be 18 | (x:-2,y:-2,w:14,h:14). Use the ref keyword to store the result in 19 | the same variable. 20 | 21 | `void Inflate(ref Rectangle rect, Size inflateSize)` 22 | 23 | `Note:` Rectangle and Size are structs defined in the System.Drawing assembly. 24 | 25 | ## Search in a list 26 | 27 | Write a method which takes a list of strings as an argument and a 28 | string to search for. If any of the strings in the list contains 29 | the searched string (as a substring), the method should return 30 | `true`. Otherwise it should return `false`. The first index 31 | of a string which contains the searched one should be stored 32 | in the `out` parameter. 33 | 34 | `bool TryFindSubstring(List list, string searched, out foundIndex)` 35 | 36 | ## Joining strings 37 | 38 | Write a method which takes an arbitrary number of strings and joins them 39 | using the specified separator. 40 | 41 | `string JoinStrings(string separator, params string[] strings)` 42 | 43 | ## Factorial generator 44 | 45 | Write a method which generates all the factorials of the integers up to n. 46 | Use the yield operator. 47 | 48 | `IEnumerable GenerateFactorials(int n)` 49 | 50 | ## Directory traversal 51 | 52 | Write a method which iterates through the contents of a directory 53 | and the contents of all its subdirectories. Use the yield operator 54 | to return the name of each entry and sub-entry. 55 | 56 | `IEnumerable IterateDirectory(DirectoryInfo dir)` 57 | 58 | * [How to create DirectoryInfo](https://msdn.microsoft.com/en-us/library/system.io.directoryinfo.directoryinfo%28v=vs.110%29.aspx) 59 | * [DirectoryInfo methods](https://msdn.microsoft.com/en-us/library/system.io.directoryinfo%28v=vs.110%29.aspx) 60 | 61 | `Hint`: use the GetDirectories method to get all subdirectories and the 62 | GetFiles method to get all files in a directory. -------------------------------------------------------------------------------- /week02/03-SourceControl/README.md: -------------------------------------------------------------------------------- 1 | # Source Control Systems - Git and TFS 2 | 3 | ## Some Git fun 4 | 5 | Create a new directory and create a new local Git repo there. 6 | 7 | Make a new file called `hello` with the following content: 8 | 9 | ``` 10 | This is line one. 11 | This is line two. 12 | This is line three. 13 | This is line four. 14 | ``` 15 | 16 | Now commit. You get an error? Did you remember to `add`? 17 | 18 | Now create a new branch called `panda` and switch to it. 19 | 20 | Change the second line of `hello` with `Uh, I forgot how to count!` and add a fifth line `This is line five.`. 21 | 22 | Commit this and switch back to the master branch. 23 | 24 | Now change the third line of `hello` with `I am number three.` and remove the fourth line. Commit. 25 | 26 | We will now simulate something called a **merge conflict**. A merge conflict happens when we attempt to merge two files when it is not obvious how to merge them (e.g. when the file has been modified from two different branches as in this case). 27 | 28 | While on the `master` branch, merge it with the `panda` branch. You will see the error. 29 | 30 | In order to fix the merge conflict, we need to use a merge tool. First make sure you have configured git to use [Visual Studio as a merge tool](https://github.com/HackBulgaria/Programming101-CSharp/blob/master/week02/README.md#working-with-git) 31 | 32 | Now run `git mergetool` and Visual Studio merge tool should be started. Get familiar with the interface. We want the file to look like this after the merge: 33 | 34 | ``` 35 | This is line one. 36 | Uh, I forgot how to count! 37 | I am number three. 38 | This is line five. 39 | ``` 40 | ### Commit it all to GitHub 41 | 42 | This is a big one. Go to our repository and note how our directories are structured. 43 | 44 | ``` 45 | |--week01 46 | | |--1.Tuesday 47 | | |--2.Thursday 48 | | |--3.Saturday 49 | | 50 | |--week02 51 | |--1.Tuesday 52 | |--2.Thursday 53 | |--3.Saturday 54 | ``` 55 | 56 | Your task is to create a GitHub repo of your own. Add all of your solutions to your repo and **use the same directory structure**. 57 | 58 | __Hint: Instead of manually creating the directories, you can clone our repo and then integrate it with your GitHub repo.__ 59 | 60 | You will need to push all of your solutions to GitHub from now on. We will sometimes review your code and give you feedback directly through GitHub. 61 | 62 | ## Working with TFS 63 | 64 | Create a free account at [Visual Studio Online](https://www.visualstudio.com/products/visual-studio-team-services-vs). Create a TFS repository there. 65 | 66 | Make sure the TFS version control plugin is enabled in Visual Studio. 67 | 68 | Connect to Visual Studio Online from Visual Studio: https://www.visualstudio.com/get-started/code/share-your-code-in-tfvc-vs 69 | 70 | Create a new solution inside your working directory and add it to the source control. Get familiar with the source control interface 71 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/Fractions.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fractions", "Fractions\Fractions.csproj", "{8DCBD502-FE49-47DC-88B7-25764C25F97F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FractionsApplication", "FractionsApplication\FractionsApplication.csproj", "{80A33C93-ED4A-49F6-B96D-8B966C585078}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8DCBD502-FE49-47DC-88B7-25764C25F97F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {8DCBD502-FE49-47DC-88B7-25764C25F97F}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {8DCBD502-FE49-47DC-88B7-25764C25F97F}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {8DCBD502-FE49-47DC-88B7-25764C25F97F}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {80A33C93-ED4A-49F6-B96D-8B966C585078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {80A33C93-ED4A-49F6-B96D-8B966C585078}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {80A33C93-ED4A-49F6-B96D-8B966C585078}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {80A33C93-ED4A-49F6-B96D-8B966C585078}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/Fractions/Fractions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8DCBD502-FE49-47DC-88B7-25764C25F97F} 8 | Library 9 | Properties 10 | Fractions 11 | Fractions 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/Fractions/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Fractions")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Fractions")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8dcbd502-fe49-47dc-88b7-25764c25f97f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/FractionsApplication/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/FractionsApplication/FractionsApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {80A33C93-ED4A-49F6-B96D-8B966C585078} 8 | Exe 9 | Properties 10 | FractionsApplication 11 | FractionsApplication 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {8dcbd502-fe49-47dc-88b7-25764c25f97f} 55 | Fractions 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/FractionsApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using Fractions; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace FractionsApplication 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | Fraction a = new Fraction(1, 2); 15 | a.Denominator = 3; 16 | 17 | Fraction b = new Fraction(4, 6); 18 | 19 | Console.WriteLine(a); 20 | Console.WriteLine(b); 21 | 22 | Console.WriteLine(a + b); 23 | Console.WriteLine(a - b); 24 | Console.WriteLine(a * b); 25 | Console.WriteLine(a / b); 26 | 27 | Console.WriteLine(a + 2.5); 28 | 29 | Console.WriteLine((double)b); 30 | 31 | Console.WriteLine(a+a == b); 32 | 33 | //Fraction c = new Fraction(3, 0); 34 | 35 | Console.ReadKey(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Fractions/FractionsApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FractionsApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FractionsApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("80a33c93-ed4a-49f6-b96d-8b966c585078")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/Vector.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vector", "Vector\Vector.csproj", "{9D5242B6-C4B0-42A8-9439-5F5ECA46FD71}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorsApplication", "VectorsApplication\VectorsApplication.csproj", "{072C1B39-67EF-463E-B51B-C433AE9F3A4E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {9D5242B6-C4B0-42A8-9439-5F5ECA46FD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {9D5242B6-C4B0-42A8-9439-5F5ECA46FD71}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {9D5242B6-C4B0-42A8-9439-5F5ECA46FD71}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {9D5242B6-C4B0-42A8-9439-5F5ECA46FD71}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {072C1B39-67EF-463E-B51B-C433AE9F3A4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {072C1B39-67EF-463E-B51B-C433AE9F3A4E}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {072C1B39-67EF-463E-B51B-C433AE9F3A4E}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {072C1B39-67EF-463E-B51B-C433AE9F3A4E}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/Vector/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Vector")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Vector")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9d5242b6-c4b0-42a8-9439-5f5eca46fd71")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/Vector/Vector.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9D5242B6-C4B0-42A8-9439-5F5ECA46FD71} 8 | Library 9 | Properties 10 | Vector 11 | Vector 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/VectorsApplication/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/VectorsApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Vectors; 7 | 8 | namespace VectorsApplication 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | Vector a = new Vector(1, 2, 4); 15 | Vector b = new Vector(2, 2, 0); 16 | 17 | Console.WriteLine(a); 18 | Console.WriteLine(b); 19 | 20 | Vector c = 2.5 * a + b; 21 | Console.WriteLine(c); 22 | 23 | Console.WriteLine(a * b); 24 | 25 | Console.WriteLine(b == new Vector(2, 2, 0)); 26 | 27 | Console.ReadKey(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/VectorsApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("VectorsApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("VectorsApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("072c1b39-67ef-463e-b51b-c433ae9f3a4e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/01-IntroToOOP/solutions/Vector/VectorsApplication/VectorsApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {072C1B39-67EF-463E-B51B-C433AE9F3A4E} 8 | Exe 9 | Properties 10 | VectorsApplication 11 | VectorsApplication 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {9d5242b6-c4b0-42a8-9439-5f5eca46fd71} 55 | Vector 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BouncingBallProject", "BouncingBallProject\BouncingBallProject.csproj", "{EEA53736-BCC8-4F9A-952C-E9F702E0A64B}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {EEA53736-BCC8-4F9A-952C-E9F702E0A64B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {EEA53736-BCC8-4F9A-952C-E9F702E0A64B}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {EEA53736-BCC8-4F9A-952C-E9F702E0A64B}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {EEA53736-BCC8-4F9A-952C-E9F702E0A64B}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BouncingBallProject 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // Form1 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.ClientSize = new System.Drawing.Size(776, 415); 38 | this.Name = "Form1"; 39 | this.Text = "Form1"; 40 | this.ResumeLayout(false); 41 | 42 | } 43 | 44 | #endregion 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace BouncingBallProject 11 | { 12 | public partial class Form1 : Form 13 | { 14 | Point center = new Point(100, 100); 15 | Point direction = new Point(3, 0); 16 | int radius = 50; 17 | 18 | Timer timer = new Timer(); 19 | 20 | public Form1() 21 | { 22 | InitializeComponent(); 23 | this.BackColor = Color.White; 24 | this.DoubleBuffered = true; 25 | this.timer.Interval = 30; 26 | this.timer.Tick += timer_Tick; 27 | this.timer.Start(); 28 | } 29 | 30 | protected override void OnPaint(PaintEventArgs e) 31 | { 32 | base.OnPaint(e); 33 | e.Graphics.FillEllipse(Brushes.Blue, center.X - radius, center.Y - radius, 2 * radius, 2 * radius); 34 | 35 | center.Offset(direction); 36 | if (center.X > this.Width && direction.X > 0) 37 | { 38 | direction.X = -direction.X; 39 | } 40 | if (center.X < 0 && direction.X < 0) 41 | { 42 | direction.X = -direction.X; 43 | } 44 | } 45 | 46 | void timer_Tick(object sender, EventArgs e) 47 | { 48 | this.Invalidate(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace BouncingBallProject 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BouncingBallProject")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BouncingBallProject")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("88f079e0-9fcd-4599-b29b-1436d0d39f93")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BouncingBallProject.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BouncingBallProject.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BouncingBallProject.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/BouncingBallProject/BouncingBallProject/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShopInventory", "ShopInventory\ShopInventory.csproj", "{CC052B73-BC30-4F97-AB77-86C4F1F117D7}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShopInventoryApplication", "ShopInventoryApplication\ShopInventoryApplication.csproj", "{230572F4-21CB-434F-BE2F-B9C772DFA862}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {CC052B73-BC30-4F97-AB77-86C4F1F117D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {CC052B73-BC30-4F97-AB77-86C4F1F117D7}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {CC052B73-BC30-4F97-AB77-86C4F1F117D7}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {CC052B73-BC30-4F97-AB77-86C4F1F117D7}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {230572F4-21CB-434F-BE2F-B9C772DFA862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {230572F4-21CB-434F-BE2F-B9C772DFA862}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {230572F4-21CB-434F-BE2F-B9C772DFA862}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {230572F4-21CB-434F-BE2F-B9C772DFA862}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/CountryVatTax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class CountryVatTax 10 | { 11 | public string CountryId { get; private set; } 12 | public double VatTax { get; private set; } 13 | public bool IsDefault { get; private set; } 14 | 15 | public CountryVatTax(string countryId, double vatTax, bool isDefault) 16 | { 17 | CountryId = countryId; 18 | VatTax = vatTax; 19 | IsDefault = isDefault; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/NotAvailableInInventoryException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class NotAvailableInInventoryException: ApplicationException 10 | { 11 | public int ProductId { get; private set; } 12 | public int ProductQuantity { get; private set; } 13 | 14 | public NotAvailableInInventoryException(int productId, int productQuantity):base(GetMessage(productId, productQuantity)) 15 | { 16 | ProductId = productId; 17 | ProductQuantity = productQuantity; 18 | } 19 | 20 | private static string GetMessage(int productId, int productQuantity) 21 | { 22 | return string.Format("Product with id {0} and quantity {1} not available in inventory", productId, productQuantity); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/NotSupportedCountryException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class NotSupportedCountryException : ApplicationException 10 | { 11 | public string CountryId { get; private set; } 12 | 13 | public NotSupportedCountryException(string countryId):base(GetMessage(countryId)) 14 | { 15 | CountryId = countryId; 16 | } 17 | 18 | private static string GetMessage(string countryId) 19 | { 20 | return string.Format("Country {0} not supported", countryId); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class Order 10 | { 11 | public IReadOnlyList ProductIds { get; private set; } 12 | public IReadOnlyList ProductQuantities { get; private set; } 13 | 14 | public Order(IList productIds, IList productQuantities) 15 | { 16 | if (productIds.Count == productQuantities.Count) 17 | { 18 | ProductIds = new List(productIds); 19 | ProductQuantities = new List(productQuantities); 20 | } 21 | else 22 | { 23 | throw new ArgumentException("The number of product ids and quantities do not match"); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class Product 10 | { 11 | public int Id { get; private set; } 12 | public string Name { get; private set; } 13 | public string CountryId { get; private set; } 14 | public double SinglePrice { get; private set; } 15 | public int Quantity { get; private set; } 16 | 17 | public double SinglePriceWithTax { get; private set; } 18 | 19 | public Product(int id, string name, string countryId, double singlePrice, int quantity, VatTaxCalculator vatTaxCalculator) 20 | { 21 | Id = id; 22 | Name = name; 23 | CountryId = countryId; 24 | SinglePrice = singlePrice; 25 | Quantity = quantity; 26 | 27 | SinglePriceWithTax = SinglePrice + vatTaxCalculator.CalculateTax(CountryId, SinglePrice); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ShopInventory")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ShopInventory")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("cc052b73-bc30-4f97-ab77-86c4f1f117d7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/ShopInventory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class ShopInventory 10 | { 11 | private List products; 12 | 13 | public ShopInventory(IList products) 14 | { 15 | this.products = new List(products); 16 | } 17 | 18 | public double Audit() 19 | { 20 | //shorter version using LINQ: 21 | //return products.Sum(p => p.SinglePriceWithTax * product.Quantity); 22 | 23 | double sum = 0; 24 | foreach(var product in products) 25 | { 26 | sum += product.SinglePriceWithTax * product.Quantity; 27 | } 28 | return sum; 29 | } 30 | 31 | public double RequestOrder(Order order) 32 | { 33 | double sum = 0; 34 | for(int i = 0; i < order.ProductIds.Count; i++) 35 | { 36 | bool success = false; 37 | 38 | //shorter version using LINQ: 39 | //var product = products.FirstOrDefault(p => p.Id == order.ProductIds[i]); 40 | Product product = null; 41 | foreach (var p in products) 42 | { 43 | if (p.Id == order.ProductIds[i]) 44 | { 45 | product = p; 46 | break; 47 | } 48 | } 49 | 50 | if(product != null && product.Quantity >= order.ProductQuantities[i]) 51 | { 52 | sum += product.SinglePriceWithTax * order.ProductQuantities[i]; 53 | success = true; 54 | } 55 | 56 | if(!success) 57 | { 58 | throw new NotAvailableInInventoryException(order.ProductIds[i], order.ProductQuantities[i]); 59 | } 60 | } 61 | 62 | return sum; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/ShopInventory.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CC052B73-BC30-4F97-AB77-86C4F1F117D7} 8 | Library 9 | Properties 10 | ShopInventory 11 | ShopInventory 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventory/VatTaxCalculator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShopInventory 8 | { 9 | public class VatTaxCalculator 10 | { 11 | private List taxes; 12 | private CountryVatTax defaultTax; 13 | 14 | public VatTaxCalculator(IList taxes) 15 | { 16 | this.taxes = new List(taxes); 17 | 18 | //shorter version using LINQ: 19 | //defaultTax = this.taxes.FirstOrDefault(t => t.IsDefault); 20 | foreach(var t in this.taxes) 21 | { 22 | if(t.IsDefault) 23 | { 24 | defaultTax = t; 25 | break; 26 | } 27 | } 28 | 29 | if(defaultTax == null) 30 | { 31 | throw new ArgumentException("No default tax"); 32 | } 33 | } 34 | 35 | public double CalculateTax(string countryId, double productPrice) 36 | { 37 | //shorter version using LINQ: 38 | //var tax = taxes.FirstOrDefault(t => t.CountryId == countryId); 39 | CountryVatTax tax = null; 40 | foreach (var t in taxes) 41 | { 42 | if (t.CountryId == countryId) 43 | { 44 | tax = t; 45 | break; 46 | } 47 | } 48 | 49 | if (tax != null) 50 | { 51 | return CalculateTax(tax, productPrice); 52 | } 53 | else 54 | { 55 | throw new NotSupportedCountryException(countryId); 56 | } 57 | } 58 | 59 | public double CalculateTax(double productPrice) 60 | { 61 | return CalculateTax(defaultTax, productPrice); 62 | } 63 | 64 | private double CalculateTax(CountryVatTax tax, double productPrice) 65 | { 66 | return tax.VatTax * productPrice; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventoryApplication/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventoryApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using ShopInventory; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ShopInventoryApplication 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | var inventory = GetInventory(); 15 | 16 | Console.WriteLine(string.Format("Audit: {0}", inventory.Audit())); 17 | 18 | var order = new Order( 19 | new int[] { 1, 3, 5 }, 20 | new int[] { 5, 7, 100 } 21 | ); 22 | 23 | Console.WriteLine(string.Format("RequestOrder: {0}", inventory.RequestOrder(order))); 24 | 25 | Console.ReadKey(); 26 | } 27 | 28 | private static ShopInventory.ShopInventory GetInventory() 29 | { 30 | var taxes = new CountryVatTax[] 31 | { 32 | new CountryVatTax("BG", 0.2, true), 33 | new CountryVatTax("GB", 0.3, false), 34 | new CountryVatTax("US", 0.4, false), 35 | new CountryVatTax("ISIS", 10, false), 36 | new CountryVatTax("ZAMUNDA", 0, false) 37 | }; 38 | 39 | var calculator = new VatTaxCalculator(taxes); 40 | 41 | var products = new Product[] 42 | { 43 | new Product(1, "BG Apples", "BG", 2, 10, calculator), 44 | new Product(2, "BG Pears", "BG", 3, 15, calculator), 45 | new Product(3, "GB Apples", "GB", 5, 10, calculator), 46 | new Product(4, "ISIS Apples", "ISIS", 100, 10, calculator), 47 | new Product(5, "ZAMUNDA Apples", "ZAMUNDA", 0, 99999, calculator) 48 | }; 49 | 50 | return new ShopInventory.ShopInventory(products); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventoryApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ShopInventoryApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ShopInventoryApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("230572f4-21cb-434f-be2f-b9c772dfa862")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week03/03-AgainOOP/solutions/ShopInventory/ShopInventoryApplication/ShopInventoryApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {230572F4-21CB-434F-BE2F-B9C772DFA862} 8 | Exe 9 | Properties 10 | ShopInventoryApplication 11 | ShopInventoryApplication 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {cc052b73-bc30-4f97-ab77-86c4f1f117d7} 55 | ShopInventory 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /week03/README.md: -------------------------------------------------------------------------------- 1 | # Week03 - Introduction to Object Oriented Programming 2 | 3 | This week we will get familiar with the basic OOP concepts in .Net and C#. 4 | 5 | ## Introduction to OOP 6 | 7 | * [OOP in general](https://www.youtube.com/watch?v=lbXsrHGhBAU) 8 | * [OOP on MSDN](https://msdn.microsoft.com/en-us/library/dd460654.aspx) 9 | * [Introduction to OOP](http://www.codeproject.com/Articles/22769/Introduction-to-Object-Oriented-Programming-Concep) 10 | 11 | ## Value and reference types, classes and structs 12 | 13 | * [Value and reference types](https://msdn.microsoft.com/en-us/library/4d43ts61%28v=vs.90%29.aspx) 14 | * [Classes and structs](http://stackoverflow.com/questions/13049/whats-the-difference-between-struct-and-class-in-net/13275#13275) 15 | * [Classes](https://msdn.microsoft.com/en-us/library/x9afc042.aspx) 16 | * [Structs](https://msdn.microsoft.com/en-us/library/saxz13w4.aspx) 17 | * [Objects](https://msdn.microsoft.com/en-us/library/ms173110.aspx) 18 | 19 | ## More on classes in .Net 20 | 21 | * [Constructors](https://msdn.microsoft.com/en-us/library/ms173115.aspx) 22 | * [Access modifiers](https://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx) 23 | * [The Object type](https://msdn.microsoft.com/en-us/library/system.object.aspx) - all .net objects inherit it and its methods. Most important methods - `ToString()`, `GetHashCode()`, `Equals()` 24 | * When overriding 'Equals()' and overloading operator==, always override `GetHashCode()` if you intend to use the class as a key in a Dictionary, otherwise you'll get unexpected results: [Why is it important to override GetHashCode() when Equals() method is overriden](http://stackoverflow.com/questions/371328/why-is-it-important-to-override-gethashcode-when-equals-method-is-overridden/371348#371348) 25 | * Properties and Indexers 26 | * [Properties](https://msdn.microsoft.com/en-us/library/65zdfbdt.aspx) 27 | * [Indexers](https://msdn.microsoft.com/en-us/library/2549tw02.aspx) 28 | * [Choosing Between Properties and Methods](https://msdn.microsoft.com/library/ms229054%28v=vs.100%29.aspx) 29 | * [.Net equality](http://www.codeproject.com/Articles/18714/Comparing-Values-for-Equality-in-NET-Identity-and) - `Equals()` vs `ReferenceEquals()` vs `==` 30 | * [Operator overloading](http://www.codeproject.com/Articles/178309/Operator-Overloading-in-C-NET) 31 | * [Static members](https://msdn.microsoft.com/en-us/library/aa645629%28v=vs.71%29.aspx) 32 | 33 | ## Other 34 | 35 | * [Namespaces](https://msdn.microsoft.com/en-us/library/dfb3cx8s.aspx) 36 | * [Enums](https://msdn.microsoft.com/en-us/library/sbbt4032.aspx) 37 | -------------------------------------------------------------------------------- /week04/01-GenericType/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Week04 - Generic Types - using the built-in generic collections 3 | 4 | ## Rewrite Pair class from the privous lessons (week 3) to support generic types 5 | 6 | ## Generic Stack class 7 | The following methods which must be implemented in Stack class : 8 | * Constructor() 9 | * Peek() - Returns the object at the top of the Stack without removing it 10 | * Pop() - Removes and returns the object at the top of the Stack 11 | * Push(T) - Inserts an object at the top of the Stack 12 | * Clear() - Removes all objects from the Stack 13 | * Contains(T) Determines whether an element is in the Stack 14 | 15 | ## Generic Dequeue class (double-ended queue) 16 | 17 | It must be based on List or T[] array. 18 | The following methods that must be implemented in Dequeue class : 19 | 20 | * Constructor() 21 | * Clear() - Removes all objects from the Dequeue 22 | * Contains(T) - Determines whether an element is in the Dequeue 23 | * T RemoveFromFront() - Removes and returns an object at the beginning of the Dequeue 24 | * T RemoveFromEnd() - Removes and returns an object at the end of the Dequeue 25 | * AddToFront(T) - Adds an object to the beginning of the Dequeue 26 | * AddToEnd(T) - Adds an object to the end of the Dequeue 27 | * T PeekFromFront() - Returns the object at the beginning of the Dequeue without removing it. 28 | * T PeekFromEnd() - Returns the object at the end of the Dequeue without removing it. 29 | 30 | ## LottoGame class 31 | 32 | * Create a LottoGame class 33 | * Create an immutable class Combination{T, U} which accepts 6 values(int, bool, double, etc.). 34 | * Override Equals and GetHashCode methods in order to check if two combinations are identical 35 | * The group of first three values shares the same C# type (Valid for the second group of three values as well) 36 | * The LottoGame class should have a constructor with a parameter of type Combination{T, U} - the winning combination of the game 37 | * Ask the user to enter any number of combinations he wants 38 | * Validate if a combination is already entered 39 | * Create an AddUserCombination method in LottoGame class which adds another user combination to the game (all the combinations must be stored internally in LottoGame class) 40 | * Create a private GetWinning combination method in TotoGame class which returns the secret winning combination 41 | * Create a Validate method in LottoGame class which returns the result from the game. The method should return an object from LottoResult class. 42 | * LottoResult class must have two properties (IsWinning - bool and MatchedNumbersCount - byte) 43 | * Print the result if a combination is winning - there is at least 1 matching value from the first group and second group or more than 1 matching value from the any of the groups 44 | 45 | Combination example : 46 | {1, 2, 3, "pesho", "gosho", "ivan"}, in the case the first three values are integers and the second three values are string 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /week04/README.md: -------------------------------------------------------------------------------- 1 | # Week04 - Generic Types - using the built-in generic collections 2 | 3 | This week we will get familiar with Generic Types in .Net and C#. 4 | 5 | ## Generic Types 6 | 7 | * [Generics on MSDN](https://msdn.microsoft.com/en-us/library/512aeb7t.aspx) 8 | * [Essential C# Generics](http://www.codeproject.com/Articles/15409/Essential-C-Chapter-Generics) 9 | * [C# Generics Benefits](https://msdn.microsoft.com/en-us/library/b5bx6xee.aspx) 10 | * [Parameters](https://msdn.microsoft.com/en-us/library/0zk36dx2.aspx) 11 | * [Constraints on Type Parameters](https://msdn.microsoft.com/en-us/library/d5x73970.aspx) 12 | * [Classes](https://msdn.microsoft.com/en-us/library/sz6zd40f.aspx) 13 | * [Methods](https://msdn.microsoft.com/en-us/library/twcad0zb.aspx) 14 | * [Arrays](https://msdn.microsoft.com/en-us/library/ms228502.aspx) 15 | * [Generics in Run time](https://msdn.microsoft.com/en-us/library/f4a6ta2h.aspx) 16 | * [Collections](https://msdn.microsoft.com/en-us/library/system.collections.generic.aspx) 17 | * [default keyword](https://msdn.microsoft.com/en-us/library/xwth0h0d.aspx) 18 | 19 | ## Generic Collections 20 | 21 | * [Collections](https://msdn.microsoft.com/en-us/library/system.collections.generic(v=vs.110).aspx) 22 | * [Stack](https://msdn.microsoft.com/en-us/library/3278tedw(v=vs.110).aspx) 23 | * [Queue](https://msdn.microsoft.com/en-us/library/7977ey2c(v=vs.110).aspx) 24 | * [List](https://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx) 25 | * [Dictionary](https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx) 26 | * [Sorted Set](https://msdn.microsoft.com/en-us/library/dd412070(v=vs.110).aspx) 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/Shapes.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShapesDesktopApplication", "ShapesDesktopApplication\ShapesDesktopApplication.csproj", "{22DFBB80-E875-4C6F-BC96-704B339C7DEC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shapes", "Shapes\Shapes.csproj", "{41789615-EE97-4303-84B2-C1CEC57D0768}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {22DFBB80-E875-4C6F-BC96-704B339C7DEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {22DFBB80-E875-4C6F-BC96-704B339C7DEC}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {22DFBB80-E875-4C6F-BC96-704B339C7DEC}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {22DFBB80-E875-4C6F-BC96-704B339C7DEC}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {41789615-EE97-4303-84B2-C1CEC57D0768}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {41789615-EE97-4303-84B2-C1CEC57D0768}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {41789615-EE97-4303-84B2-C1CEC57D0768}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {41789615-EE97-4303-84B2-C1CEC57D0768}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/Shapes/IDisplayable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Shapes 8 | { 9 | public interface IDisplayable 10 | { 11 | System.Drawing.Color Color { get; set; } 12 | void Draw(System.Drawing.Graphics g); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/Shapes/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Shapes")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Shapes")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("41789615-ee97-4303-84b2-c1cec57d0768")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/Shapes/Rectangle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Shapes 8 | { 9 | public class Rectangle : IDisplayable 10 | { 11 | public System.Drawing.Color Color { get; set; } 12 | 13 | public Rectangle() 14 | { 15 | Color = System.Drawing.Color.Yellow; 16 | } 17 | 18 | public void Draw(System.Drawing.Graphics g) 19 | { 20 | System.Drawing.Pen pen = new System.Drawing.Pen(Color); 21 | g.DrawRectangle(pen, 20, 50, 100, 40); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/Shapes/Shapes.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {41789615-EE97-4303-84B2-C1CEC57D0768} 8 | Library 9 | Properties 10 | Shapes 11 | Shapes 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 56 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/MainForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ShapesDesktopApplication 2 | { 3 | partial class MainForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.pnlDrawArea = new System.Windows.Forms.Panel(); 32 | this.SuspendLayout(); 33 | // 34 | // pnlDrawArea 35 | // 36 | this.pnlDrawArea.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 37 | | System.Windows.Forms.AnchorStyles.Left) 38 | | System.Windows.Forms.AnchorStyles.Right))); 39 | this.pnlDrawArea.Location = new System.Drawing.Point(12, 12); 40 | this.pnlDrawArea.Name = "pnlDrawArea"; 41 | this.pnlDrawArea.Size = new System.Drawing.Size(578, 327); 42 | this.pnlDrawArea.TabIndex = 0; 43 | this.pnlDrawArea.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlDrawArea_Paint); 44 | // 45 | // Form1 46 | // 47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 49 | this.ClientSize = new System.Drawing.Size(602, 351); 50 | this.Controls.Add(this.pnlDrawArea); 51 | this.Name = "Form1"; 52 | this.Text = "Shapes"; 53 | this.ResumeLayout(false); 54 | 55 | } 56 | 57 | #endregion 58 | 59 | private System.Windows.Forms.Panel pnlDrawArea; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace ShapesDesktopApplication 11 | { 12 | public partial class MainForm : Form 13 | { 14 | private List displayableObjects; 15 | 16 | public MainForm() 17 | { 18 | InitializeComponent(); 19 | 20 | displayableObjects = new List(); 21 | displayableObjects.Add(new Shapes.Rectangle()); 22 | } 23 | 24 | private void pnlDrawArea_Paint(object sender, PaintEventArgs e) 25 | { 26 | foreach(var obj in displayableObjects) 27 | { 28 | obj.Draw(e.Graphics); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace ShapesDesktopApplication 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ShapesDesktopApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ShapesDesktopApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("22dfbb80-e875-4c6f-bc96-704b339c7dec")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ShapesDesktopApplication.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShapesDesktopApplication.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ShapesDesktopApplication.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /week05/02-Inheritance/Shapes/ShapesDesktopApplication/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /week06/01 - Exceptions/README.md: -------------------------------------------------------------------------------- 1 | ### Implement a XmlMarkupBuilder class ### 2 | Make an easy to use XmlMarkupBuilder class, which creates a **valid xml** 3 | 4 | We won't worry about namespaces here. By valid, I mean having the `` declaration, and having only tags, attributes, and text between a tag opening and tag closing. 5 | 6 | For instance: 7 | ``` 8 | 9 | attr 10 | 11 | 12 | 13 | 14 | Hey dude check it out 15 | why are you out of scope, man? 16 | 17 | 18 | ``` 19 | 20 | Your class should support these operations: 21 | ```CSharp 22 | XmlMarkupBuilder openTag(String tagName); 23 | XmlMarkupBuilder addAttr(String attrName, String attrValue); // valid only when you have a tag opened! 24 | XmlMarkupBuilder addText(String text); 25 | XmlMarkupBuilder closeTag(); //close the last opened tag. 26 | XmlMarkupBuilder finish(); //close all tags and finelize your object. Any open,addAttr or other calls to your object, should throw an Exception. 27 | String getResult(); //let's stay close to http://en.wikipedia.org/wiki/Builder_pattern 28 | ``` 29 | 30 | Example usages of your `XmlMarkupBuilder` class 31 | ```CSharp 32 | XmlMarkupBuilder markupBuilder = new XmlMarkupBuilder(); 33 | 34 | //http://en.wikipedia.org/wiki/Fluent_interface ftw 35 | String validMarkup = markupBuilder.openTag("body").addAttr("background","0xFF0000").addText("Helo HTML!").finalize().getResult(); 36 | markupBuilder.closeTag() //BOOOM! Object finalized! Exception! 37 | ............... 38 | XmlMarkupBuilder markupBuilder = new XmlMarkupBuilder(); 39 | markupBuilder.openTag("a").closeTag().openTag("a") //BOOOM! You need to have a root XML object, XML is not a list! 40 | ............... 41 | XmlMarkupBuilder markupBuilder = new XmlMarkupBuilder(); 42 | markupBuilder.openTag("a").closeTag().closeTag() //BOOOM! What the hell are we closing?! 43 | ............... 44 | XmlMarkupBuilder markupBuilder = new XmlMarkupBuilder(); 45 | markupBuilder.openTag("a").closeTag().addAttribute("href","https://www.youtube.com/watch?v=P5ft_7Bcyc4") //BOOOM! What are you adding attribute to? 46 | 47 | and so on and so on 48 | ``` -------------------------------------------------------------------------------- /week06/README.md: -------------------------------------------------------------------------------- 1 | ##Exceptions 2 | This week we will be talking about exceptions. Here are some materials: 3 | * [Good Practices](http://www.codeproject.com/Articles/9538/Exception-Handling-Best-Practices-in-NET) 4 | * [Exception Handling - MDN](https://msdn.microsoft.com/en-us/library/ms173162.aspx) 5 | * [Exception class - MDN](https://msdn.microsoft.com/en-us/library/system.exception(v=vs.110).aspx) 6 | 7 | ## Unit tests 8 | Last time we talked about unit tests, here are some materials to refresh your memory: 9 | * [Creating unit tests - MDN](https://msdn.microsoft.com/en-us/library/ms182532.aspx) 10 | * [Introduction to TDD](http://www.agiledata.org/essays/tdd.html) 11 | 12 | ## Delegates and Events 13 | 14 | * [Delegates and Events](https://msdn.microsoft.com/en-us/library/orm-9780596521066-01-17.aspx) 15 | * [Delegates and Events part 2](http://csharpindepth.com/Articles/Chapter2/Events.aspx) 16 | * [Delegates and Events part 3](http://www.c-sharpcorner.com/UploadFile/84c85b/delegates-and-events-C-Sharp-net/) 17 | 18 | 19 | ## Static Classes and Static Constructors 20 | 21 | * [Static Classes and members](https://msdn.microsoft.com/en-us/library/79b3xss3.aspx) 22 | * [Static Constructors](https://msdn.microsoft.com/en-us/library/k9x6w0hc.aspx) 23 | 24 | ## Anonymous Types and Nested Classes 25 | 26 | * [Anonymous Types](https://msdn.microsoft.com/en-us/library/bb397696.aspx) 27 | * [Nested Classes](https://msdn.microsoft.com/en-us/library/ms173120.aspx) 28 | 29 | ## Partial Classes and Methods 30 | 31 | * [Partial Classes](https://msdn.microsoft.com/en-us/library/wa80x488.aspx) 32 | * [Partial Methods](https://msdn.microsoft.com/library/6b0scde8(v=vs.110).aspx) 33 | -------------------------------------------------------------------------------- /week07/01-Linq-Basics/Readme.md: -------------------------------------------------------------------------------- 1 | # Anonymous Methods, Lambda Expressions, Linq 2 | 3 | ## Anonymous method 4 | 5 | Rewrite AverageAggregator problem by using anonymous methods 6 | 7 | ## Lambda Expressions 8 | 9 | Rewrite NotifyCollection problem by using lambda expressions 10 | 11 | ## LINQ 12 | 13 | Create several classes : 14 | class Product with the following properties: 15 | `Name : string,` 16 | `ProductId : int,` 17 | `CategoryId : int` 18 | 19 | class Order with the following properties: 20 | `OrderId : int,` 21 | `Products : List,` 22 | `OrderDate : DateTime,` 23 | `Name : string` 24 | 25 | class Category with the following properties : 26 | `CategoryId : int`, 27 | `CategoryName : string` 28 | 29 | Implement class DataStore which has the following three static methods : 30 | * GetProducts() : returns a list with all products, ProductIds should be between 1 and 100 31 | * GetCategories() : returns a list with all categories, CategoriesIds should be between 101 and 200 32 | * GetOrders() : returns a list with all orders, OrderIds should be between 201 and 300 33 | 34 | Write following queries in your Main method by using the results from the methods in DataStore class 35 | * Create linq query which returns all products with ids between 15 and 30 36 | * Create linq query which returns all categories with ids between 105 and 125 37 | * Create linq query which returns first 15 orders sorted by order name 38 | * Create linq query which returns first 3 orders which contains a specific productId (e.g. 10). 39 | Orders must be sorted based on OrderDate 40 | The print order names. 41 | * Create linq query which returns all product with the name of the category which they belong to. 42 | Order the result based on CategoryName 43 | The result must be printed to the console. 44 | * Create linq query which returns all categories together with their products 45 | 46 | Create class CategoryWithProduct which should keep the result 47 | the class CategoryWithProduct must conrtain the following properties : 48 | `CategoryName : string,` 49 | `ProductNames : List,` 50 | `CategoryId : int` 51 | 52 | 53 | * Create linq query which selects all orders together with their products and then print it to the screen. 54 | 55 | For every product print its category name as well. 56 | Sort the result by orderDate. 57 | -------------------------------------------------------------------------------- /week07/02 - Introduction to SQL/Readme.md: -------------------------------------------------------------------------------- 1 | ## Queries 2 | We will be using the Microsoft Adventure Works Database for this Exercies 3 | http://msftdbprodsamples.codeplex.com/releases/view/55330 4 | 5 | #Select statement exercises 6 | 7 | Enter select statements to: 8 | * Display the first name for everyone that's in the table. 9 | * Display the first name, last name, and city for everyone that's not from Payson. 10 | * Display all columns for everyone that is over 40 years old. 11 | * Display the first and last names for everyone whose last name ends in an "ay". 12 | * Display all columns for everyone whose first name equals "Mary". 13 | * Display all columns for everyone whose first name contains "Mary". 14 | 15 | #Update statement exercises 16 | 17 | After each update, issue a select statement to verify your changes. 18 | * Jonie Weber just got married to Bob Williams. She has requested that her last name be updated to Weber-Williams. 19 | * Dirk Smith's birthday is today, add 1 to his age. 20 | * All secretaries are now called "Administrative Assistant". Update all titles accordingly. 21 | * Everyone that's making under 30000 are to receive a 3500 a year raise. 22 | * Everyone that's making over 33500 are to receive a 4500 a year raise. 23 | * All "Programmer II" titles are now promoted to "Programmer III". 24 | * All "Programmer" titles are now promoted to "Programmer II". 25 | 26 | 27 | #Some more selections: 28 | * Show OrdeQty, the Name and the ListPrice of the order made by CustomerID 635 29 | * Show all the addresses listed for 'Modular Cycle Systems' 30 | * A "Single Item Order" is a customer order where only one item is ordered. Show the SalesOrderID and the UnitPrice for every Single Item Order. 31 | * Where did the racing socks go? List the product name and the CompanyName for all Customers who ordered ProductModel 'Racing Socks'. 32 | * Show the product description for culture 'fr' for product with ProductID 736 33 | * Use the SubTotal value in SaleOrderHeader to list orders from the largest to the smallest. For each order show the CompanyName and the SubTotal and the total weight of the order. 34 | * How many products in ProductCategory 'Cranksets' have been sold to an address in 'London'? 35 | * For every customer with a 'Main Office' in Dallas show AddressLine1 of the 'Main Office' and AddressLine1 of the 'Shipping' address - if there is no shipping address leave it blank. Use one row per customer. 36 | * For each order show the SalesOrderID and SubTotal calculated three ways: 37 | A) From the SalesOrderHeader 38 | B) Sum of OrderQty*UnitPrice 39 | C) Sum of OrderQty*ListPrice 40 | * Show the best selling item by value. 41 | -------------------------------------------------------------------------------- /week07/Readme.md: -------------------------------------------------------------------------------- 1 | ## Anonymous Methods 2 | * [Anonymous Methods](https://msdn.microsoft.com/en-us/library/0yw3tz5k.aspx) 3 | 4 | ## LINQ Prerequisites: 5 | * [Implicitly Typed Local Variables](https://msdn.microsoft.com/en-us/library/bb384061.aspx) 6 | * [Object and Collection Initializers](https://msdn.microsoft.com/en-us/library/bb384062.aspx) 7 | * [Lambda Expressions](https://msdn.microsoft.com/en-us/library/bb397687.aspx) 8 | * [Anonymous Types (C# Programming Guide)](https://msdn.microsoft.com/en-us/library/bb397696.aspx) 9 | * [Extension Methods](https://msdn.microsoft.com/en-us//library/bb383977.aspx) 10 | 11 | ## LINQ: 12 | * [Lambda Expressions with LINQ queries](https://msdn.microsoft.com/en-us/library/bb397675.aspx) 13 | * [LINQ MSDN](https://msdn.microsoft.com/en-us/library/bb397926.aspx) 14 | * [Introduction to LINQ](https://msdn.microsoft.com/en-us/library/bb397897.aspx) 15 | * [101 samples in LINQ](https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b) 16 | * [Query syntax vs Method syntax](https://msdn.microsoft.com/en-us/library/bb397947.aspx) 17 | 18 | ## SQL 19 | [SQL Server Express 2014](https://www.microsoft.com/en-us/download/details.aspx?id=42299) 20 | [SELECTS](https://msdn.microsoft.com/en-us/library/ms189499.aspx) 21 | [UPDATE](https://msdn.microsoft.com/en-us/library/ms177523.aspx) 22 | [DELETE](https://msdn.microsoft.com/en-us/library/ms189835.aspx) 23 | [CREATE](https://msdn.microsoft.com/en-us/library/ms174979.aspx) -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/StudentGroups.md: -------------------------------------------------------------------------------- 1 | Димитър, Александър 2 | 3 | Тони, Благой 4 | 5 | Мартин, Иван Руски 6 | 7 | Петя, Виктор 8 | 9 | Натали, Иван Български/Петров 10 | 11 | Велко, Ивайло 12 | 13 | Станислав, Божидар 14 | 15 | Стефан, Николай 16 | 17 | Дилян, Радин 18 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFS.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BFSLibrary", "BFSLibrary\BFSLibrary.csproj", "{287CC5F9-3571-4CAC-A5C0-005A9E2059CE}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BFSApplication", "BFSApplication\BFSApplication.csproj", "{63507D3F-87AA-45D7-B15C-C4F4E4878E77}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {287CC5F9-3571-4CAC-A5C0-005A9E2059CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {287CC5F9-3571-4CAC-A5C0-005A9E2059CE}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {287CC5F9-3571-4CAC-A5C0-005A9E2059CE}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {287CC5F9-3571-4CAC-A5C0-005A9E2059CE}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {63507D3F-87AA-45D7-B15C-C4F4E4878E77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {63507D3F-87AA-45D7-B15C-C4F4E4878E77}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {63507D3F-87AA-45D7-B15C-C4F4E4878E77}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {63507D3F-87AA-45D7-B15C-C4F4E4878E77}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSApplication/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSApplication/BFSApplication.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {63507D3F-87AA-45D7-B15C-C4F4E4878E77} 8 | Exe 9 | Properties 10 | BFSApplication 11 | BFSApplication 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {287cc5f9-3571-4cac-a5c0-005a9e2059ce} 55 | BFSLibrary 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using BFSLibrary; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace BFSApplication 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | var graph = GetGraph(); 15 | 16 | var connections = BFS.FindConnections(graph[0]); 17 | var level = BFS.FindConnectionLevel(graph[0], graph[4]); 18 | } 19 | 20 | private static List> GetGraph() 21 | { 22 | var node1 = new GraphNode("node1"); 23 | var node2 = new GraphNode("node2"); 24 | var node3 = new GraphNode("node3"); 25 | var node4 = new GraphNode("node4"); 26 | var node5 = new GraphNode("node5"); 27 | var node6 = new GraphNode("node6"); 28 | var node7 = new GraphNode("node6"); 29 | 30 | node1.Neighbours.Add(node3); 31 | 32 | node2.Neighbours.Add(node3); 33 | node2.Neighbours.Add(node4); 34 | 35 | node3.Neighbours.Add(node1); 36 | node3.Neighbours.Add(node2); 37 | node3.Neighbours.Add(node4); 38 | 39 | node4.Neighbours.Add(node2); 40 | node4.Neighbours.Add(node3); 41 | node4.Neighbours.Add(node5); 42 | 43 | node5.Neighbours.Add(node4); 44 | node5.Neighbours.Add(node6); 45 | node5.Neighbours.Add(node7); 46 | 47 | node6.Neighbours.Add(node5); 48 | 49 | node7.Neighbours.Add(node5); 50 | 51 | return new List>() 52 | { 53 | node1, node2, node3, node4, node5, node6, node7 54 | }; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BFSApplication")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BFSApplication")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("63507d3f-87aa-45d7-b15c-c4f4e4878e77")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSLibrary/BFS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BFSLibrary 8 | { 9 | public static class BFS 10 | { 11 | public static List> FindConnections(GraphNode startNode) 12 | { 13 | var visited = new List>(); 14 | var queue = new Queue>(); 15 | 16 | visited.Add(startNode); 17 | queue.Enqueue(startNode); 18 | 19 | while(queue.Count > 0) 20 | { 21 | var node = queue.Dequeue(); 22 | 23 | foreach(var neighbour in node.Neighbours) 24 | { 25 | if(!visited.Contains(neighbour)) 26 | { 27 | visited.Add(neighbour); 28 | queue.Enqueue(neighbour); 29 | } 30 | } 31 | } 32 | 33 | return visited; 34 | } 35 | 36 | public static int FindConnectionLevel(GraphNode startNode, GraphNode endNode) 37 | { 38 | var visited = new List>(); 39 | var queue = new Queue>(); 40 | 41 | visited.Add(startNode); 42 | queue.Enqueue(new GraphNodeWithLevel() 43 | { 44 | Node = startNode, 45 | Level = 0 46 | }); 47 | 48 | while (queue.Count > 0) 49 | { 50 | var nodeWithLevel = queue.Dequeue(); 51 | 52 | if(nodeWithLevel.Node == endNode) 53 | { 54 | return nodeWithLevel.Level; 55 | } 56 | 57 | foreach (var neighbour in nodeWithLevel.Node.Neighbours) 58 | { 59 | if (!visited.Contains(neighbour)) 60 | { 61 | visited.Add(neighbour); 62 | queue.Enqueue(new GraphNodeWithLevel() 63 | { 64 | Node = neighbour, 65 | Level = nodeWithLevel.Level + 1 66 | }); 67 | } 68 | } 69 | } 70 | 71 | return -1; 72 | } 73 | 74 | private class GraphNodeWithLevel 75 | { 76 | public GraphNode Node { get; set; } 77 | public int Level { get; set; } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSLibrary/BFSLibrary.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {287CC5F9-3571-4CAC-A5C0-005A9E2059CE} 8 | Library 9 | Properties 10 | BFSLibrary 11 | BFSLibrary 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSLibrary/GraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BFSLibrary 8 | { 9 | public class GraphNode 10 | { 11 | T Value { get; set; } 12 | public List> Neighbours { get; private set; } 13 | 14 | public GraphNode(T value) 15 | { 16 | Value = value; 17 | Neighbours = new List>(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /week08/02-PandaSocialNetwork/solutions/BFS/BFSLibrary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BFSLibrary")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BFSLibrary")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("287cc5f9-3571-4cac-a5c0-005a9e2059ce")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /week09/02-ADO.NET/README.md: -------------------------------------------------------------------------------- 1 | # ADO.NET Problems 2 | 3 | ## Hack Company 4 | 5 | We'll create a library that consumes the database from [last time](https://github.com/HackBulgaria/Programming101-CSharp/tree/master/week08/03-SQL-DatabaseDesign) 6 | 7 | As usual create a library project for our library and a console application for interface. Put the connection string to the database in the App.config of the console application. 8 | 9 | ### DTO classes 10 | 11 | Usually when communicating with an external service we use so called [DTO objects](https://en.wikipedia.org/wiki/Data_transfer_object). These are simple objects that only store the necessary information that is transferred to the service. 12 | 13 | Create DTO objects for every table in the HackCompany database. For example, the employee will be: 14 | ```csharp 15 | public class Employee 16 | { 17 | public int Id {get; set} 18 | public string Name {get; set} 19 | public string Email {get; set} 20 | public DateTime BirthDate {get; set} 21 | public int? ManagerId {get; set} 22 | public int? DepartmentId {get; set} 23 | } 24 | ``` 25 | 26 | ### Communicating with the database 27 | 28 | Create a utility class with methods for communicating with the database: 29 | * For each database object create a method that accepts an appropriate DTO object and: 30 | * If a row with the same Id already exists update it 31 | * If a row with the same Id doesn't exist insert it. After that update the Id of the DTO object with the newly inserted Id (you can use the [@@IDENTITY](https://msdn.microsoft.com/en-us/library/ms187342.aspx) function to return the last inserted Id) 32 | * For each database object create a method that accepts an Id and deletes the database row with that Id. It returns true/false indicating if the deletion was successful 33 | * For each database object create a method that returns a list of DTO objects - all rows in the database 34 | * For each database object create a method that accepts an Id and returns the appropriate DTO object with that Id. If there is no such Id in the database return null. 35 | 36 | ## Panda Social Network 37 | 38 | Create a database for the [Panda Social Network](https://github.com/HackBulgaria/Programming101-CSharp/tree/master/week08/02-PandaSocialNetwork) with the appropriate tables in it. 39 | 40 | After that in your solution in a separate project create a class `PandaSocialNetworkAdoNetStorageProvider` that loads and saves the Panda Network in the database. Use the above method with creating DTO classes first if needed. 41 | -------------------------------------------------------------------------------- /week10/01 - Books With LinqToSQL/README.md: -------------------------------------------------------------------------------- 1 | # Introduction to the task 2 | Just as the Hello World is a rigth of passsage to programming, the book database is the right of passage to SQL Development. 3 | The task for today is to create a pesronal book manager. It will be able to track your books, track the book loanage and help you organize. 4 | 5 | In the real world clients will have requirements and you, as an awesome developer, will need to find out what your classes will need to be 6 | and what will the database schema look like. So it will be your task to design them. 7 | 8 | # Entities 9 | 10 | ## Book 11 | Of course at the center of our library will be a book. 12 | It should atleast have the following properties: 13 | 14 | * Title 15 | * Authors - One book can have more then one author. 16 | * Description/Resume 17 | * DatePublished 18 | * Publisher - The name of the book publisher 19 | * Genre - Could one book have more than one genre ? 20 | * Pages 21 | * ISBN 22 | 23 | Do note that you may have more than one copy of a book. And yet you will want to knwo which copy is loaned to whom. 24 | 25 | ## Author 26 | 27 | * First Name 28 | * Last Name 29 | * Year Born 30 | * Year Died 31 | * Books Written 32 | 33 | ## Users 34 | Users cannot own books from the library. They can only loan books, as such you will most likely want their contact information: 35 | 36 | * First Name 37 | * Last Name 38 | * Pseudonim 39 | * Email 40 | * Phone 41 | 42 | # The application 43 | The application will be a console application and will need to do the following tasks: 44 | 45 | * Insert a new book 46 | 47 | * Insert a new author 48 | 49 | * Get all books contained in the library - sorted in alphabetical order by title. 50 | 51 | * Get all books contained in the library sorted by author. 52 | 53 | * Get all books sorted by gendre. 54 | 55 | * Get all types of genders a given author has written. For instance: 56 | J. R. R. Tolkien has written: Fantasy, High fantasy, literacy criticism. 57 | 58 | * Get all books written by a given author 59 | Sergei Lukyanenko has written: 60 | 1) Night Watch 61 | 2) Day Watch 62 | 63 | * Get the complete information(everything about the book and its authors) of a book by its ISBN 64 | 65 | * Get the complete information Title(part of the title should also be accepted) - If there are more than one books with the same title get the fist one 66 | If we search for information about: *Lord of the* we might get: 67 | *Lord of the Rings*, *Lord of the dance* or what ever else we have in the library. 68 | 69 | * Loan a book to a user: 70 | * It would be healthy for your library to add some constraint for how many books a given user can take 71 | * You will want to keep track of the books you give to other people - to whom you have given WHAT book, when you have given it away and when do you expect it. 72 | * you should mark when a book is returned. 73 | * It will be up to you to think how to know which book has been given away, and wich is not. 74 | 75 | -------------------------------------------------------------------------------- /week10/02 - Ticket System/README.md: -------------------------------------------------------------------------------- 1 | #Some helpful methods 2 | ## Password security 3 | * [How to handle hash and salt](https://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx) 4 | 5 | Ticket system part one 6 | Recently we have noticed that the experience of buying a ticket for a train or bus is somewhat cumbersome. So we are going to make a superior system(and maybe make some money out of it). 7 | This project will be implemented in multiple classes. 8 | So to start building the system we will need to define some base entities. 9 | 10 | ##Cities 11 | * Name 12 | 13 | ##Trains 14 | * Identifier 15 | * Seats – Where each seat can be first or second class 16 | * Brief description 17 | 18 | ##Schedule 19 | * Starting City 20 | * End City 21 | * BONUS: Remember each city stop 22 | * Travel Time 23 | * The train with which the trip will be made 24 | * Ticket price 25 | 26 | ##User 27 | * Email 28 | * User name 29 | * two users cannot have the same user name or email 30 | * Password – The password should not be stored in plain text 31 | * Discount Card Number 32 | * Credit Card Number – Again not in plain text / the SVC should not be stored at all. 33 | * Address 34 | * Zip Code 35 | * First name 36 | * Last name 37 | 38 | ##Ticket 39 | * TripDateAndTime 40 | * Original Price 41 | * Price sold 42 | * UserSoldTo 43 | * SeatNumber 44 | 45 | ##Discount Card 46 | * ID 47 | * Type – students/isic etc 48 | * Discount amount 49 | * Applies to first class – true/false 50 | 51 | ##The app must have the following functionalities: 52 | ###City wise: 53 | * Get all cities 54 | * Add a city 55 | * Delete a city 56 | 57 | ###Train wise: 58 | * Get a list of trains 59 | * Add a train 60 | * Edit a train 61 | * Delete a train 62 | 63 | ###Schedule wise 64 | * Display the full schedule 65 | * Add a trip – if the train is not in use – for now let us just take that it will teleport from place a to place after the trip is over (it is not safe for humans) 66 | * Edit an existing trip 67 | * Get all trips from city A to city B 68 | 69 | ###Tickets 70 | * Every user should buy a ticket, if the seat he wants to buy is not taken. 71 | -------------------------------------------------------------------------------- /week10/README.md: -------------------------------------------------------------------------------- 1 | #ORMs 2 | This week we will start exploring Object relational mappers 3 | 4 | ## LINQ to SQL 5 | [YouTube tutorial](https://www.youtube.com/watch?v=bsncc8dYIgY) 6 | 7 | [MDN tutorial](https://msdn.microsoft.com/en-us/library/bb425822.aspx) 8 | 9 | [LINQtoSQL - onother tutorial](http://weblogs.asp.net/scottgu/using-linq-to-sql-part-1) 10 | 11 | ## Entity Framework 6 12 | 13 | [A very comperhensive website tutorial](http://www.entityframeworktutorial.net/EntityFramework5/entity-framework5-introduction.aspx) 14 | 15 | [YouTube tutorial](https://www.youtube.com/watch?v=t7wlW4CWh8s) 16 | 17 | [CodeFirst exsmple](https://msdn.microsoft.com/en-us/data/jj193542.aspx) 18 | -------------------------------------------------------------------------------- /week11/01 - Windows Forms/README.md: -------------------------------------------------------------------------------- 1 | # Tasks 2 | 3 | ## Calculator 4 | 5 | Write a basic calculator application. 6 | 7 | * The calculator should support the basic operators: +,-,*,/ 8 | * In addition, the functions sqrt, log2 and ln should also be supported 9 | * Fractional numbers should also be supported 10 | 11 | ## Text auto correct 12 | 13 | Write a text pad which auto-corrects you as you type. 14 | 15 | The program should read the words dictionary from a file. Here is a [sample one](http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt) 16 | 17 | For each written word (after you press space next to the word), the program should 18 | check if the word exists in the dictionary and if it does not, replace it with the 19 | most similar to it which exists in the dictionary. 20 | 21 | To determine similarity between words, you can count the number of positions 22 | in which two words differ. 23 | 24 | ## File browser 25 | 26 | Write a simple file browser with a TreeView and a ListView. 27 | 28 | * The TreeView should display the folder structure of drive C:\ (folders only). 29 | * When you select a folder from the TreeView, its contents should be display in the ListView. 30 | * Double clicking a folder in the ListView should open the folder. 31 | * Double clicking a file in the ListView should open it with the associated program for it. 32 | -------------------------------------------------------------------------------- /week11/02 - WPF/README.md: -------------------------------------------------------------------------------- 1 | # Tasks 2 | 3 | ## Stylish Calculator 4 | 5 | Rewrite the calculator from the previous exercise using WPF. 6 | 7 | Reuse the logic for it, but create WPF styles for the buttons. 8 | 9 | Create three different themes for it - Light, Blue, Dark 10 | 11 | ## Employee editor 12 | 13 | Create a program which lists all employees from the HackCompany database you created in week08. 14 | 15 | List all employees from the table in a listbox/listview. 16 | 17 | Add editors which allow you to edit the info (Name/Email/BirthDate) of the selected employee. 18 | 19 | Use appropriate editors for each field and try to validate the input in the email field. 20 | 21 | Showing a validation error if the field contains incorrect data. 22 | 23 | Use either WPF or Windows Forms for this task. -------------------------------------------------------------------------------- /week11/03 - Train System App/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackBulgaria/Programming101-CSharp/bda6a6630cee3ace6deb98f1436990a091a0f08d/week11/03 - Train System App/README.md -------------------------------------------------------------------------------- /week12/02 - MVVM/Northwind.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackBulgaria/Programming101-CSharp/bda6a6630cee3ace6deb98f1436990a091a0f08d/week12/02 - MVVM/Northwind.bak -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WpfApplication2 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/DataAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WpfApplication2 8 | { 9 | static class DataAccess 10 | { 11 | static NORTHWNDEntities context = new NORTHWNDEntities(); 12 | 13 | public static NORTHWNDEntities Context { get { return context; } } 14 | 15 | public static void SaveChanges() 16 | { 17 | context.SaveChanges(); 18 | } 19 | 20 | public static List GetEmployeesWithNonNullCountry() 21 | { 22 | return 23 | context.Employees. 24 | Where(x => !String.IsNullOrEmpty(x.Country)).ToList(); 25 | } 26 | 27 | public static List GetProductsForOrder(int orderId) 28 | { 29 | var order = context.Orders.Where(x => x.OrderID == orderId).FirstOrDefault(); 30 | if(order == null) 31 | { 32 | return new List(); 33 | } 34 | 35 | return order.Order_Details.Select(x => x.Product).ToList(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Employee.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace WpfApplication2 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class Employee 16 | { 17 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] 18 | public Employee() 19 | { 20 | this.Employees1 = new HashSet(); 21 | this.Orders = new HashSet(); 22 | } 23 | 24 | public int EmployeeID { get; set; } 25 | public string LastName { get; set; } 26 | public string FirstName { get; set; } 27 | public string Title { get; set; } 28 | public string TitleOfCourtesy { get; set; } 29 | public Nullable BirthDate { get; set; } 30 | public Nullable HireDate { get; set; } 31 | public string Address { get; set; } 32 | public string City { get; set; } 33 | public string Region { get; set; } 34 | public string PostalCode { get; set; } 35 | public string Country { get; set; } 36 | public string HomePhone { get; set; } 37 | public string Extension { get; set; } 38 | public byte[] Photo { get; set; } 39 | public string Notes { get; set; } 40 | public Nullable ReportsTo { get; set; } 41 | public string PhotoPath { get; set; } 42 | 43 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 44 | public virtual ICollection Employees1 { get; set; } 45 | public virtual Employee Employee1 { get; set; } 46 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 47 | public virtual ICollection Orders { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/EmployeesWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | 23 | 26 | 29 | 30 | 31 | 32 | 33 | FirstName 34 | 36 | 37 | 38 | LastName 39 | 41 | 42 | 43 | Address 44 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/EmployeesWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace WpfApplication2 18 | { 19 | /// 20 | /// Interaction logic for MainWindow.xaml 21 | /// 22 | public partial class EmployeesWindow : Window 23 | { 24 | MainWindowViewModel viewModel = new MainWindowViewModel(); 25 | public EmployeesWindow() 26 | { 27 | InitializeComponent(); 28 | this.DataContext = this.viewModel; 29 | } 30 | 31 | private void employeesGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) 32 | { 33 | this.viewModel.SelectedEmployee = 34 | this.employeesGrid.SelectedItem as Employee; 35 | } 36 | 37 | private void Button_Click(object sender, RoutedEventArgs e) 38 | { 39 | DataAccess.SaveChanges(); 40 | } 41 | } 42 | 43 | public class MainWindowViewModel : INotifyPropertyChanged 44 | { 45 | private Employee selectedEmployee; 46 | 47 | public List Employees 48 | { 49 | get 50 | { 51 | return DataAccess.Context.Employees.ToList(); 52 | } 53 | } 54 | 55 | public Employee SelectedEmployee 56 | { 57 | get 58 | { 59 | return selectedEmployee; 60 | } 61 | set 62 | { 63 | selectedEmployee = value; 64 | this.OnPropertyChanged("SelectedEmployee"); 65 | } 66 | } 67 | 68 | protected virtual void OnPropertyChanged(string property) 69 | { 70 | if(this.PropertyChanged != null) 71 | { 72 | this.PropertyChanged(this, new PropertyChangedEventArgs(property)); 73 | } 74 | } 75 | 76 | public event PropertyChangedEventHandler PropertyChanged; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/NorhtwindModel.Context.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace WpfApplication2 11 | { 12 | using System; 13 | using System.Data.Entity; 14 | using System.Data.Entity.Infrastructure; 15 | 16 | public partial class NORTHWNDEntities : DbContext 17 | { 18 | public NORTHWNDEntities() 19 | : base("name=NORTHWNDEntities") 20 | { 21 | } 22 | 23 | protected override void OnModelCreating(DbModelBuilder modelBuilder) 24 | { 25 | throw new UnintentionalCodeFirstException(); 26 | } 27 | 28 | public virtual DbSet Employees { get; set; } 29 | public virtual DbSet Order_Details { get; set; } 30 | public virtual DbSet Orders { get; set; } 31 | public virtual DbSet Products { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/NorhtwindModel.Designer.cs: -------------------------------------------------------------------------------- 1 | // T4 code generation is enabled for model 'c:\users\ivant\documents\visual studio 2015\Projects\WpfApplication2\WpfApplication2\NorhtwindModel.edmx'. 2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer 3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model 4 | // is open in the designer. 5 | 6 | // If no context and entity classes have been generated, it may be because you created an empty model but 7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity 8 | // classes for your model, open the model in the designer, right-click on the designer surface, and 9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation 10 | // Item...'. -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/NorhtwindModel.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/NorhtwindModel.edmx.diagram: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Order.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace WpfApplication2 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class Order 16 | { 17 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] 18 | public Order() 19 | { 20 | this.Order_Details = new HashSet(); 21 | } 22 | 23 | public int OrderID { get; set; } 24 | public string CustomerID { get; set; } 25 | public Nullable EmployeeID { get; set; } 26 | public Nullable OrderDate { get; set; } 27 | public Nullable RequiredDate { get; set; } 28 | public Nullable ShippedDate { get; set; } 29 | public Nullable ShipVia { get; set; } 30 | public Nullable Freight { get; set; } 31 | public string ShipName { get; set; } 32 | public string ShipAddress { get; set; } 33 | public string ShipCity { get; set; } 34 | public string ShipRegion { get; set; } 35 | public string ShipPostalCode { get; set; } 36 | public string ShipCountry { get; set; } 37 | 38 | public virtual Employee Employee { get; set; } 39 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 40 | public virtual ICollection Order_Details { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Order_Detail.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace WpfApplication2 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class Order_Detail 16 | { 17 | public int OrderID { get; set; } 18 | public int ProductID { get; set; } 19 | public decimal UnitPrice { get; set; } 20 | public short Quantity { get; set; } 21 | public float Discount { get; set; } 22 | 23 | public virtual Order Order { get; set; } 24 | public virtual Product Product { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/OrdersWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/OrdersWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace WpfApplication2 16 | { 17 | /// 18 | /// Interaction logic for OrdersWindow.xaml 19 | /// 20 | public partial class OrdersWindow : Window 21 | { 22 | OrdersWindowViewModel viewModel = new OrdersWindowViewModel(); 23 | 24 | public OrdersWindow() 25 | { 26 | InitializeComponent(); 27 | this.DataContext = viewModel; 28 | } 29 | 30 | ProductsWindow productsWindow; 31 | 32 | private void ordersGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) 33 | { 34 | var order = this.ordersGrid.SelectedItem as Order; 35 | if(order == null) 36 | { 37 | return; 38 | } 39 | 40 | if (productsWindow == null) 41 | { 42 | productsWindow = new ProductsWindow(); 43 | productsWindow.Owner = this; 44 | } 45 | 46 | productsWindow.ViewModel = new ProductsWindowViewModel(order.OrderID); 47 | productsWindow.Show(); 48 | } 49 | } 50 | 51 | public class OrdersWindowViewModel 52 | { 53 | public List Orders 54 | { 55 | get 56 | { 57 | return DataAccess.Context.Orders.ToList(); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Product.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace WpfApplication2 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class Product 16 | { 17 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] 18 | public Product() 19 | { 20 | this.Order_Details = new HashSet(); 21 | } 22 | 23 | public int ProductID { get; set; } 24 | public string ProductName { get; set; } 25 | public Nullable SupplierID { get; set; } 26 | public Nullable CategoryID { get; set; } 27 | public string QuantityPerUnit { get; set; } 28 | public Nullable UnitPrice { get; set; } 29 | public Nullable UnitsInStock { get; set; } 30 | public Nullable UnitsOnOrder { get; set; } 31 | public Nullable ReorderLevel { get; set; } 32 | public bool Discontinued { get; set; } 33 | 34 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] 35 | public virtual ICollection Order_Details { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/ProductsWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/ProductsWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Shapes; 15 | 16 | namespace WpfApplication2 17 | { 18 | /// 19 | /// Interaction logic for ProductsWindow.xaml 20 | /// 21 | public partial class ProductsWindow : Window 22 | { 23 | private ProductsWindowViewModel viewModel; 24 | 25 | public ProductsWindow() 26 | { 27 | InitializeComponent(); 28 | 29 | } 30 | 31 | protected override void OnClosing(CancelEventArgs e) 32 | { 33 | base.OnClosing(e); 34 | e.Cancel = true; 35 | this.Hide(); 36 | } 37 | 38 | public ProductsWindowViewModel ViewModel 39 | { 40 | get 41 | { 42 | return viewModel; 43 | } 44 | 45 | set 46 | { 47 | viewModel = value; 48 | this.DataContext = viewModel; 49 | } 50 | } 51 | } 52 | 53 | public class ProductsWindowViewModel 54 | { 55 | List list; 56 | 57 | public ProductsWindowViewModel(int orderId) 58 | { 59 | list = DataAccess.GetProductsForOrder(orderId); 60 | } 61 | 62 | public List Products 63 | { 64 | get { return list; } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WpfApplication2")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WpfApplication2")] 15 | [assembly: AssemblyCopyright("Copyright © 2016")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WpfApplication2.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WpfApplication2.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WpfApplication2.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /week12/02 - MVVM/NorthwindMVVMSample/StartupWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 |