C# Workshop 3 – ShapeInheritance With Lists

This week’s workshop code is available at: http://devsoc.co.uk/wp-content/uploads/2011/12/ShapeInheritanceWithLists.zip. We covered using Lists in C# to store data, in particular using a List to store different types of objects all derived from a base class. We also covered using a Switch Case to build a basic text menu, which can also be used in C++.

In the new year we will be covering an introduction to NerfCore, so if you haven’t already, head over to http://nerfgames.co.uk/forums and get registered for your engine key.

To test your understanding of this week’s work, go back to the problem set last week and extend it to use the type of text menu we made this week, add a List to store objects, write the ToString overrides and have a go at implementing a Search by Name and BubbleSort. The last two will be a bit of a challenge, but are both manageable, so give them a go!

C# Workshop 2 – ShapeInheritance

This week’s workshop is available at http://devsoc.co.uk/wp-content/uploads/2011/12/ShapeInheritance-fixed.zip. I’ve included a bunch of comments to explain what each part does and also included an example of a second level of inheritance, inheriting the Rectangle from the Square, which inherits from the Shape.

To test if you understand the concepts behind this, try creating your own C# project and creating an abstract Person class to store Name and Age, and then create Staff and Student classes that inherit from the Person class. The Staff class should store data about their office and module that they teach, the student class should have a course that they are enrolled on and a grade for first year.

Next week we will be introducing Lists to store collections of data, Getters and Setters and overriding methods from the C# base object class to make outputting data about an object easier. Don’t worry if this sounds confusing, it’ll make sense by the end of the workshop!