Thread: Requesting a challenge

  1. #1
    1479
    Join Date
    Aug 2003
    Posts
    253

    Requesting a challenge

    Hello everyone. I was wondering if anyone here could post a challenge on classes. I have been tinkering about and around with them for a while now and I want something that will challenge me.

    The biggest problem I am having with C++is finding out how to use them for something practical. Thats why I can't come up with my own class exercises. If anyone could help me out and give me a decent challenge I would be very thankful.
    Knowledge is power and I want it all

    -0RealityFusion0-

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    Classes and Sturcts are probably the most useful and practical thing in C++ and C. You want a challenge? Just try making an RPG or something with lots of information, and classes will will be a big part.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    Make a text-based simulation using classes... (ie how about a simulation of ten people walking around). You'll probably have an array of your class type, each representing one individual person. You figure out why kind of information needs to be stored about each person. You can store the area in which everybody can walk as a 2D array. You can base the movement of each person as a pattern, or just make it random. Make it as easy or as complicated as you want.
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  4. #4
    1479
    Join Date
    Aug 2003
    Posts
    253
    that sounds great! Thanks!
    Knowledge is power and I want it all

    -0RealityFusion0-

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Originally posted by funkydude9
    Make a text-based simulation using classes... (ie how about a simulation of ten people walking around). You'll probably have an array of your class type, each representing one individual person. You figure out why kind of information needs to be stored about each person. You can store the area in which everybody can walk as a 2D array. You can base the movement of each person as a pattern, or just make it random. Make it as easy or as complicated as you want.
    then add 'personalities' and action functionions to the people. ex) if person 1 with personality type 0 is standing beside another person, he will punch him. The person being punched then reacts based on their personality type. welcome to basic AI interaction

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    Originally posted by Perspective
    then add 'personalities' and action functionions to the people. ex) if person 1 with personality type 0 is standing beside another person, he will punch him. The person being punched then reacts based on their personality type. welcome to basic AI interaction
    Then add the ability for the people the drive cars, and rob banks, and shoot people. Before you know it you'll have made a GTA clone!
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  7. #7
    1479
    Join Date
    Aug 2003
    Posts
    253
    I only have one question about doing all this. When I am making my classes what should I make public and what should be private. I am going to do some research about public and private class types. I honestly don't see any reason to make anything private but I don't know much about programming either
    Knowledge is power and I want it all

    -0RealityFusion0-

  8. #8
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Making things private stops code from the outside from messin' with your variables. That way, your class can take care of itself... which becomes important as the class gets larger and more complex. For very very basic ones, it doesn't matter too much.
    Away.

  9. #9
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Typically, all of your data (variables) are private. There really should be no need for outside code (with the exception of friend classes/functions) to access these parts. Making classes like this does a few things:

    1) Allows any changes to be validated first (possibly throwing exceptions if necessary).
    2) Prevents objects from entering invalid states easily (insuring that all variables are properly updated when a change is made). (Though some types of objects may still be able to enter invalid states - a socket connection lost, or something - the class can deal with it, and prevent invalid data from being treated as though it is valid.)
    3) Makes client code dependent upon a particular interface, not a particular implementation.

    Just to name a few.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programming Challenge (for my school)
    By Ezerhorden in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2006, 06:56 AM
  2. Calc challenge
    By cerin in forum C++ Programming
    Replies: 5
    Last Post: 02-06-2005, 04:57 PM
  3. Speed Challenge, my solution:
    By RoD in forum C++ Programming
    Replies: 11
    Last Post: 03-17-2003, 09:12 PM
  4. A Challenge!
    By Silentsharp in forum C++ Programming
    Replies: 20
    Last Post: 02-14-2002, 09:46 PM