Class Libraries / Classes & Focusing on OOP

This was actually a challenge lesson from a course I’ve been taking. The lesson instructor actually gave us some program requirements. The challenge was a dart game of 300. I had to create a re-usable class library for the Darts class that has to be used by the 300 game. The idea was that this class could be used no matter what type of dart game was being played. Be it a game of 300, high score game, etc… Each game could refer to this class library for the basic methods, properties etc.., to function. This game was really simple in¬† nature. Each player has 3 chances, or darts to throw each round. The first player to get 300 or more wins the game. Sounds simple huh? It was actually¬† more involved the more I got into programming this along with following the requirements. I won’t list ALL of the requirements as you can guess they got pretty involved. Things like what the score was if the dart hit the inner bulls-eye or outer bulls-eye, if the darts lands in the inner or outer bands, calculating and updating the score, displaying the results, etc… And trying to keep my methods within 6-10 lines of code. Whew!!!! Again if you want to download the source-code you can via the download page. I’ve included comments in the code to try and explain what I’m doing the best that I can. It will probably help some of the gaps because I’ll no doubt leave holes in my descriptions below. And if you have any questions leave a comment below. I will probably come back to this program later and add more classes to the class library based on different types of games. maybe, so stay tuned.

Continue reading

More Fun With Classes (Hero & Monster Revision)

This is a revision of a previous blog posting of the Hero & Monster fight program. I decided to do some actual class seperation of the Character, Dice, and DisplayResult classes. I decided to also incorporate some private methods along with public methods in these classes that other parts of the program could use. I know that this program is really small in scale so you might be thinking why seperate things out? Well this will show the ability to use different classes based on the program function at any partcicular runtime. And how you can use public and private methods inside the classes to do work and generate results.

Continue reading

Fun With Class Libraries

Here I’m going to show how you can use class libraries so you can use the same code across multiple applications. This can save time on typing multiple lines of the same code across different types of applications. For the example I’ll use code from a class library in an ASP form along with a Windows application. Now you might run into some issues along the way. Such as formatting that I ran into going from an ASP application to a WinForm application.

You can find the source code to both the ASP and C# Winforms Downloads section.

Continue reading