dcsimg
Results 1 to 6 of 6

Thread: Class explanation needed

  1. #1

    Thread Starter
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 2012
    Posts
    140

    Class explanation needed




    Can someone explain me how all this work what I wroten?
    Attached Images Attached Images  

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,128

    Re: Class explanation needed

    That's really quite a stupid class as far as I can tell. From what you've posted there, that Names enumeration is completely pointless as it's not being used at all. As it stands, that class simply defines a type of object that has a Name of type String. You can create instances and when you do, you must provide a Name for that instance. You can then get that Name or change it if and when you like. The enumeration serves no useful purpose as it stands.

  3. #3

    Thread Starter
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 2012
    Posts
    140

    Re: Class explanation needed

    enumeration is just left from another thing I was doing there. But besides that I am learning the classes so just wanted to realize how it function. For example, why I create propertie as public string name and inside type get; and set;I watched some tutorial but it's not well explained.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,128

    Re: Class explanation needed

    Think about adventure role-playing games. The classic such game had three character classes: warrior, wizard and cleric. Note the word "class". None of those three things was a character itself. It is a description of the type of characters you can create. Programming classes are the same. They describe a type of object that you can create. As the name suggests, classes are the way types of objects are classified. Any object with some specific group of members is this class of object and any object with some other set of members is some other class of object.

    In the aforementioned game, when you want to play you have to create a character. You decide which class you want to play as and the game will generate a default character based on the standard template and you then get to customise it by setting things like the strength and stamina. In programming terms, that is instantiating the class, i.e. creating an object of that type, and then setting the appropriate properties. In the game you will make your character perform actions like attacking, which would be the equivalent of calling a method on your programming object. When you attack, the game will check what your strength is to decide how much damage you did. That is equivalent to getting the value of a property.

    It's all fairly simple stuff really and is just an abstraction of the real world.

  5. #5

    Thread Starter
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 2012
    Posts
    140

    Re: Class explanation needed

    Ohhhh, I see things much better now. First of all , English is not my main language so it's a problem a bit to understand all those terms for me, then when programers start talking like: "This class obtain an object" or simular i get lost because I didn't understood the terms. Now, its much better with your explanation. It is simple as you said allready it just need time and a person (like you) who know so much. Thank you.

  6. #6
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: Class explanation needed

    Quote Originally Posted by jmcilhinney View Post
    Think about adventure role-playing games. The classic such game had three character classes: warrior, wizard and cleric. Note the word "class". None of those three things was a character itself. It is a description of the type of characters you can create. Programming classes are the same. They describe a type of object that you can create. As the name suggests, classes are the way types of objects are classified. Any object with some specific group of members is this class of object and any object with some other set of members is some other class of object.

    In the aforementioned game, when you want to play you have to create a character. You decide which class you want to play as and the game will generate a default character based on the standard template and you then get to customise it by setting things like the strength and stamina. In programming terms, that is instantiating the class, i.e. creating an object of that type, and then setting the appropriate properties. In the game you will make your character perform actions like attacking, which would be the equivalent of calling a method on your programming object. When you attack, the game will check what your strength is to decide how much damage you did. That is equivalent to getting the value of a property.

    It's all fairly simple stuff really and is just an abstraction of the real world.

    Very nice explanation jmc.
    I like the sykrim references.

    Parksie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width