Advertisement

C# Workshop - Week 1 (Ch. 1 & 2) - Advanced

Started by July 01, 2007 12:15 AM
337 comments, last by paulecoyote 17 years, 1 month ago
For some people this page may be of use to help them get started, it helped me.
http://www.functionx.com/csharp/
Quote: Original post by TheTroll
The main use of the static constructor is to initialize static members of your class.
*** Source Snippet Removed ***

Hope that explains it.
theTroll


Ah, I see, it was as simple as that. Isn't it possible though to give the static members a value on declaration?

Advertisement
Quote: Original post by password
Quote: Original post by TheTroll
The main use of the static constructor is to initialize static members of your class.
*** Source Snippet Removed ***

Hope that explains it.
theTroll


Ah, I see, it was as simple as that. Isn't it possible though to give the static members a value on declaration?


public class K{    private int static SOME_CONSTANT = 5;}

is indeed valid code. The static constructor is provided for the times you need to do something a bit more complex than that. See 10.4.5.
Yes you can declare a static in the declaration. What the static constructors are for is for more complex declaration. Say you need some information from the person's computer, screen size or the such and you are going to be storing that in a static. You then will need to use the static constructor.

I made a simple example so not to confuse people, what I showed would be just as easy to do in the declaration.

theTroll
I have been trying to create a game design to apply the concepts learned so far, but i don't know what should be created with what. where should classes be used, or properties. What concepts should be private and which ones should be public. Any suggestions?
here
Image Hosted by ImageShack.us
[opinion]
Experience is the best teacher for the art which is program design. As a beginner, focus on making it work. You'll learn soon enough what design patterns tend to be good, which tend to be bad, and why. And you'll learn far better the nuances and 'feel' to it which don't tend to come along with rote instruction.
[/opinion]

That is also perhaps beyond the scope of these two chapters.
Advertisement
Quote: Original post by alvarofrank
I have been trying to create a game design to apply the concepts learned so far, but i don't know what should be created with what. where should classes be used, or properties. What concepts should be private and which ones should be public. Any suggestions?
<image removed>


This workshop will teach C#, but it will not teach Object oriented design. I would suggest you go and find a good book that focuses just on that.

theTroll

Quote: Original post by alvarofrank
I have been trying to create a game design to apply the concepts learned so far, but i don't know what should be created with what. where should classes be used, or properties. What concepts should be private and which ones should be public. Any suggestions?
here
Image Hosted by ImageShack.us

Wait until the workshop starts going into the final project, which will be a text based game. You'll see a lot of what you're wondering about when you see it take shape.

Quote: Original post by alvarofrank
I have been trying to create a game design to apply the concepts learned so far, but i don't know what should be created with what. where should classes be used, or properties. What concepts should be private and which ones should be public. Any suggestions?
here
Image Hosted by ImageShack.us


In your case, you're items can be broken up as follows:

Classes (the objects in your chart)
Army
UnitPosition
Archers
Spear Infantry
etc...

Properties (the variables in your chart)
Health pts
Attack pts
Charge pts
Defense pts

Methods (the actions in your chart)
Attack
Charge
Move
Die

Enumerations (multiple choice options)
Army Formation
Terrain
Weather
Mike Popoloski | Journal | SlimDX
Quote: Original post by Mike.Popoloski
In your case, you're items can be broken up as follows:

Classes (the objects in your chart)
Army
UnitPosition
Archers
Spear Infantry
etc...

Properties (the variables in your chart)
Health pts
Attack pts
Charge pts
Defense pts

Methods (the actions in your chart)
Attack
Charge
Move
Die

Enumerations (multiple choice options)
Army Formation
Terrain
Weather

THANKS that makes all the concepts a lot more clear. Thank You for your help. Its always easier with examples.

This topic is closed to new replies.

Advertisement