Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Gone for a day or two  (Read 2402 times)

0 Members and 1 Guest are viewing this topic.

Dilbert

    Topic Starter
  • Moderator


  • Egghead

  • Welcome to ComputerHope!
  • Thanked: 44
    Gone for a day or two
    « on: December 31, 2006, 07:42:19 PM »
    Of course, when I get involved with a project, it ends up consuming all my time. I'm working on a large C++ program now to give me practice with Object-Oriented Programming and to practice making code on a large scale. (Well, large for now; I know I'll make longer programs later in life)

    This program, for a "simple" game, is taking a long time, and I may need time I'd normally spend online. So if I suddenly disappear, don't worry; I'll be back. </Schwarzenegger>

    Okay, 310 lines of code... now to write the program. ;D
    "The geek shall inherit the Earth."

    Fed

    • Moderator


    • Sage
    • Thanked: 35
      • Experience: Experienced
      • OS: Windows XP
      Re: Gone for a day or two
      « Reply #1 on: December 31, 2006, 07:47:11 PM »
      A fancy way of saying, "I'm going to format my computer".  ;D

      Dilbert

        Topic Starter
      • Moderator


      • Egghead

      • Welcome to ComputerHope!
      • Thanked: 44
        Re: Gone for a day or two
        « Reply #2 on: December 31, 2006, 10:28:28 PM »
        LOL ;D (An update: I've finished formatting E: and can use it now.)

        No, seriously, I'm writing code. I'm checking here between member functions. A grand total of 551 lines so far. I haven't even written one line of code for int main() yet; I'm going through all those objects with functions to write. 9 functions and 1.75 objects down, about 35 to go. :o
        « Last Edit: December 31, 2006, 10:29:19 PM by Timothy_Bennett »
        "The geek shall inherit the Earth."

        street1 (RIP)

        • R.I.P.


        • Egghead

        • I Triple Dog Dare You!!! LOL
        • Thanked: 14
          • Obituary
        • Experience: Beginner
        • OS: Windows XP
        Re: Gone for a day or two
        « Reply #3 on: December 31, 2006, 11:34:57 PM »
        You are doing great Dilbert.Maybe I can plunder a little while
        you are pre-occupied.

        I can't even laugh right....I have the chortles---Bwa 'Snort' Ha

         'Snort' HaHa! :-? ;D

        Good luck with your project Dilbert.

        You want believe it.I am sitting here eating
        a ginger SNAP!
        « Last Edit: December 31, 2006, 11:38:45 PM by street1 »
        Sorry,The USA has ruined the language The United Kingdom loaned us. We do our best not to type gibberish. I Hope you can forgive us.

        Dilbert

          Topic Starter
        • Moderator


        • Egghead

        • Welcome to ComputerHope!
        • Thanked: 44
          Re: Gone for a day or two
          « Reply #4 on: January 01, 2007, 03:20:03 AM »
          Quote
          Good luck with your project Dilbert.

          Thanks. ;)

          *urf* 2:20 AM... 812 lines of code... still not to the main function yet... sooo tired... ZzZzZzZz
          "The geek shall inherit the Earth."

          Calum

          • Moderator


          • Egghead

            Thanked: 238
            • Yes
            • Yes
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Other
          Re: Gone for a day or two
          « Reply #5 on: January 01, 2007, 04:06:23 AM »
          Good luck Dilbert.

          Neil



            Expert
          • Fear me Track. Noone can escape my wrath.
          • Thanked: 3
            Re: Gone for a day or two
            « Reply #6 on: January 01, 2007, 10:41:36 AM »
            What game are you making? I was making a C chess game. I got up to 1467 lines of code before it got too complicated and disorganised it was beyond my ability. Lines in themself don't tell much either.. each person has his own preferences on how much white space to use, etc.

            Dilbert

              Topic Starter
            • Moderator


            • Egghead

            • Welcome to ComputerHope!
            • Thanked: 44
              Re: Gone for a day or two
              « Reply #7 on: January 01, 2007, 12:03:22 PM »
              I'm making a command-line interface game. I'll explain it in more detail once I've gotten every last detail down, but it revolves around my house. :)

              Each room is a separate class, or object. Normally, I'd have each object in the room inherit from the room, with its own properties, in a "has-a" relationship. However, due to the nature of the game, the member functions are various commands that can be executed. That is the purpose behind int main(): To accept commands, parse them based on what room is in use, and pass control to another parser which parses on a room-by-room basis. In a sense, I outsourced int main() for the most part. The class member functions take up the majority of the work. But I'm still writing them. Then, there's the minor setback I found this morning, which was the result of coding at midnight. :)

              When the project is tentatively complete, I'll post the game and ask for playtesters to look for bugs. That should be... interesting. I personally like to think my code is foolproof after all this coding, but I know that I have to have made mistakes.

              As for my whitespace preferences, it's rather simple: I leave blank lines between functions and classes. Classes are also broken with whitespace per section, i.e. constructors and destructors are separate from the list of possible commands, etc. I also will devote some space, if necessary, to comments. I'd say about 80% of my lines are actually used for code. :)

              EDIT: Oh, and to make sure I can read it: I liberally indent. 3 spaces for anything inside an opening brace (I've nested as far as 9), with each closing brace lined up with its partner.
              « Last Edit: January 01, 2007, 12:18:36 PM by Timothy_Bennett »
              "The geek shall inherit the Earth."

              Neil



                Expert
              • Fear me Track. Noone can escape my wrath.
              • Thanked: 3
                Re: Gone for a day or two
                « Reply #8 on: January 01, 2007, 12:21:15 PM »
                Hehe. I like to use lots of whitespace, often having blank lines within functions to seperate different sections. It seems to make my code easier to understand for me. Also what I meant was things such as {} taking up whole lines on their own.

                Indenting with spaces? Why not use tab. My C++ editor actually does most of the tabs for me automatically.
                « Last Edit: January 01, 2007, 12:22:59 PM by Neil »

                Dilbert

                  Topic Starter
                • Moderator


                • Egghead

                • Welcome to ComputerHope!
                • Thanked: 44
                  Re: Gone for a day or two
                  « Reply #9 on: January 01, 2007, 12:32:51 PM »
                  Well, I use a monospace font, so space is just as easy. Also, I edit in Notepad2, which, when in C/C++ Source mode, when you press Enter will automatically indent to wherever the previous line started.

                  Oh, and I'll also do this:

                  void myFunction()
                  {
                     //Some stuff
                  }

                  So it can look something like this (I do use extra comments if it gets this bad, which is rare):

                  void myFunction()
                  {
                     if(!myVariable)
                        {
                           for(int i = 0; i < 4; i++)
                              {
                                 //Stuff
                              }
                        }
                     else
                        {
                           //Other Stuff
                        }
                  }



                  EDIT: D'oh! I found another midnight error: I started trying to initialize member variables in the class declarations! Bad bad bad! Shame on me! (That won't compile.) ;)

                  If I keep catching these as I go, I might have at least a silver-star program. :)

                  (My key: Bronze-Star programs have only minor syntax errors, silver-star programs compile the first time, but may or may not have runtime errors or bugs, while gold-star programs have no errors from the first time it is compiled and run, forever. In other words, a "hello world" program. ;D)
                  « Last Edit: January 01, 2007, 01:16:40 PM by Timothy_Bennett »
                  "The geek shall inherit the Earth."

                  Neil



                    Expert
                  • Fear me Track. Noone can escape my wrath.
                  • Thanked: 3
                    Re: Gone for a day or two
                    « Reply #10 on: January 01, 2007, 01:09:24 PM »
                    Poor, poor Dilbert. "when you press Enter will automatically indent to wherever the previous line started" oh wow! not

                    Get Microsoft Visual C++ Express Edition - automatic indentation is the way to go. And, suprisingly for Microsoft, it's a free download.

                    for(int i = 0; i < 4, i++) missing a semi-colon?

                    I think the code looks neater like this

                    void myFunction()
                    {
                       if(!myVariable)
                            for(int i = 0; i < 4; i++)
                                  //assuming only one line here
                       else
                            //assuming only one line here
                    }

                    Of course if you need to add extra lines later, you need to add the {} again, but if you're completely sure only one line is required, this way is clearer for me.
                    « Last Edit: January 01, 2007, 01:13:25 PM by Neil »

                    Dilbert

                      Topic Starter
                    • Moderator


                    • Egghead

                    • Welcome to ComputerHope!
                    • Thanked: 44
                      Re: Gone for a day or two
                      « Reply #11 on: January 01, 2007, 01:24:36 PM »
                      Yeah, but for this project, where I have "//Stuff", it's usually a few couts, along with variables set and possibly other ifs or loops. It can get rather confusing without the braces even if it is one line.

                      Yes, I screwed up on the post and made a comma. I do intend to look over my program before I compile for that stuff, but I'm not making that kind of slip very often in the actual code.

                      Quote
                      Poor, poor Dilbert. "when you press Enter will automatically indent to wherever the previous line started" oh wow! not

                      I'll get VC++ Express. But I'll want to finish this particular project the way I'm doing it now... then use the auto-indent in the future. See, I have Bloodshed's Dev-C++, but the auto-indent is very screwed up. So... I got a little discouraged and used Notepad2, which has syntax highlighting and the like. (I particularly like the fact that when the cursor is next to a brace or parenthesis, it highlights it and its mate in bold red, so I know whether I skipped a } or a ). )
                      "The geek shall inherit the Earth."