Adblock breaks this site

Programming Stories

Discussion in 'Programming General' started by Y0u_G0t_Pwn3d, Nov 14, 2009.

Thread Status:
Not open for further replies.
  1. Y0u_G0t_Pwn3d

    Y0u_G0t_Pwn3d Guru

    Joined:
    Feb 11, 2007
    Posts:
    1,478
    Referrals:
    0
    Sythe Gold:
    0
    Programming Stories

    Tell horror stories or brag about success or just rant about languages.

    Ill start with mine:

    I've been programming in Java for about 4 days now, 2 days ago I was doing a programming exercises that came with the free book that I got off the internet. It was to simulate dice rolls and see how many rolls it took to get snake eyes. I set at my laptop for 2 hours trying to figure it out. Then today I went back and I realized I had to use a while loop. -Facepalm-
     
  2. Jimmy

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25
    Programming Stories

    Code:
    import java.lang.reflect.*;
    
    class DiceTest {
    
        private static int random() {
            return (int)(Math.random() * 6);
        }
    
        public static void main(String[] args) {
            int tries = 0;
            while(true) {
                tries++;
                int dice1 = random();
                int dice2 = random();
                if((dice1 == 1) && (dice2 == 1)) {
                    System.out.println("Snake eyes on try #" + tries);
                    break;
                }
    	}
        }
    
    }
    That took you over 2 hours? Lol..

    Let's see...I got started with HTML when I was in 4th grade because I wanted to make my own website (I have no idea why). In 5th grade, I got a book on game programming which was with blitz basic (a waste of my time, in which I learned nothing). In 6th grade, I got familiar with Java with RSPS (I was so bad, I couldn't create a HelloWorld Program on my own >__<). Then November of last year I started up with Java again. I learned stuff pretty quickly, also learned some C# (very similar to Java), as well as XML (markup, not programming language), php (scripting, not programming), and here I am now.
     
  3. ddemetrius456

    ddemetrius456 Newcomer

    Joined:
    Nov 18, 2009
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    Programming Stories

    Sorry. i have nothing 2 share... But yours one is awesome.

    _____________
    Wonderbra
     
  4. greenteashirt

    greenteashirt Active Member

    Joined:
    Feb 12, 2010
    Posts:
    135
    Referrals:
    0
    Sythe Gold:
    0
    Programming Stories

    took c++ in highschool, dropped out, never loooked back.
     
  5. super_

    super_ Member

    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0
    Programming Stories

    rofl i would say age explains your ineptitude but then again at your age i was better
     
  6. aznguy94

    aznguy94 Forum Addict

    Joined:
    Feb 11, 2007
    Posts:
    304
    Referrals:
    0
    Sythe Gold:
    0
    Programming Stories

    I'm sure if you read the book it would give you a general idea of how to do it...if not, buy a better book. lol
     
  7. b0b3rt

    b0b3rt Apprentice
    $5 USD Donor

    Joined:
    Aug 3, 2008
    Posts:
    974
    Referrals:
    0
    Sythe Gold:
    0
    Programming Stories

    Jimmy.. I understand that was probably fairly fast and rough, but your random method sucks =P

    You shouldn't rely on integer truncation, that's basically like setting each number generated to its floor value instead of actually rounding it. Which means you'll get a disproportionate amount of low numbers XD
     
  8. Jimmy

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25
    Programming Stories

    Yeah, that code is absolutely disgusting.

    This thread is quite old, too D:
     
< A request. | Favourite compiler? >
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site