ALL SOFTWARE EXERCISES
- EXERCISES HOME PAGE (893)
- Access 2010 (66)
- Access VBA Macros (17)
- Advanced VBA (29)
- DAX (0)
- Excel (0)
- Excel 2010 (83)
- Excel 2013 (10)
- Excel VBA Macros (37)
- Power BI - Excel 2013 (25)
- Power BI - Excel 2016 (24)
- Power BI Desktop (26)
- PowerPivot 2010 (26)
- Report Builder (42)
- SQL (192)
- SSAS - multidimensional (21)
- SSAS - tabular (29)
- SSIS Integration Services (40)
- SSRS 2012 (53)
- SSRS 2016 (43)
- Visual Basic (45)
- Visual C Sharp (65)
- WPF - Visual C# (20)
VISUAL C SHARP EXERCISES
- Creating forms (2)
- Coding form events (1)
- Laying out your code (2)
- C# variables (4)
- Enumerations and constants (2)
- Conditions (2)
- Modular code (3)
- Arrays (2)
- Looping (2)
- Files and folders (3)
- Properties in C# (3)
- Using lists (3)
- Validating forms (3)
- Toolbars, menus and status bars (1)
- FileDialogs and StreamReaders (1)
- Debugging and trapping errors (1)
- Introduction to DataGridViews (1)
- DataGridView events (3)
- Complex DataGridViews (2)
- Creating classes (2)
- The form as a class (1)
- Data structures (4)
- Inheritance (4)
- Interfaces (2)
- Delegates and events (2)
- Writing LINQ (1)
- Advanced LINQ (3)
- LINQ to SQL models (1)
- Writing LINQ to SQL (2)
- Grouping using LINQ (2)
Exercise: Create an interface to treat room hires and dates the same
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
The answer to the exercise will be included and explained if you attend the course listed below!
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Create a new project called Advanced_CSharp_exercises. Add the files in the folder above into a new project.
To do this, right-click on the project and choose Add --> Existing Item... Be careful to add all of the files, not just the ones of certain type.
Set the frmMeetings form to be the default one for the project, then run the project - you should now see that it gives you a very short list of invitations to send:
Each invitation has a description, an addresse and the text.
To start, have a quick look at the Venue, Customer, Tryst and RoomHire classes.
If you look at the code behind the form, you'll see that it also creates 3 venues, 3 customers, 2 trysts (dates between customers) and 2 room hires:
// create some venues
Venue RedLion = new Venue("Red Lion, High Street");
Venue CostaCoffee = new Venue("Costa Coffee, Market Street");
Venue CatholicChurch = new Venue(
"Church of Immaculate Conception, Church Road");
// create some people
Customer c1 = new Customer("Rita", "Brown");
Customer c2 = new Customer("Sue", "Jones");
Customer c3 = new Customer("Bob", "Smith");
// arrange some trysts between customers (Bob
// pessimistically meets 2 ladies)
Tryst t1 = new Tryst(c1, c3, RedLion,
new System.DateTime(2013, 11, 25, 11, 30, 0));
Tryst t2 = new Tryst(c2, c3, CostaCoffee,
new System.DateTime(2013, 11, 25, 12, 0, 0));
// now add separate room hires for speed
// dating (2 running simultaneously,
// although the Catholic Church one doesn't last as long)
DateTime whenStart = new System.DateTime(2013, 11, 22, 10, 0, 0);
RoomHire rh1 = new RoomHire(CostaCoffee,
RoomHire rh2 = new RoomHire(CatholicChurch,
Some code has been commented out:
// now create some happenings!
Your task is to add an interface called I_Happening which includes the following member:
// a happening must support a list of invitations
You'll need to amend the Tryst and RoomHire classes to implement this interface, and get them to support the required property.
Uncomment the code which is commented out. Add code to add one row to the data table for each request for each happening!
Run your program - you should get something like this:
Notice how each tryst has added two invitations: one for each person.
Close down any open files!