Cora Dyce

Welcome to our website !
Please register an account to view the complete categories and forums.


Join the forum, it's quick and easy

Cora Dyce

Welcome to our website !
Please register an account to view the complete categories and forums.

Cora Dyce

Would you like to react to this message? Create an account in a few clicks or log in to continue.

Cora Dyce - Your personal dicing clan


4 posters

    need help with coding again...

    avatar
    peasant
    Highroller
    Highroller


    Posts : 590
    Join date : 2011-06-20
    Age : 27

    Dices Rolls
    Dice Roll:

    need help with coding again... Empty need help with coding again...

    Post by peasant 2014-03-28, 23:04

    This code has to be in java.
    For my robotics class, I need 2 teams to compete against each other. Winner moves to the next round
    The teams are selected at random (simulating picking 2 teams from a hat) without replacement (math)
    Write a program that will pick 2 random teams at a time from 8 teams without replacement .

    Thanks to Allen for helping me with the other problems
    avatar
    Cannons
    Member
    Member


    Posts : 3461
    Join date : 2012-06-28
    Age : 29

    need help with coding again... Empty Re: need help with coding again...

    Post by Cannons 2014-03-28, 23:06

    {CL EXCERPT
    XY=TRUE IF NT IS Y UNLESS Y

    HUNT EXP}
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    need help with coding again... Empty Re: need help with coding again...

    Post by Allen's Slave 2014-03-28, 23:11

    My name is Tom.

    But give me a second to write it.
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    need help with coding again... Empty Re: need help with coding again...

    Post by Allen's Slave 2014-03-28, 23:18

    Code:
    public static void pair(){
    ArrayList<String> pool = new ArrayList<String>();

    Random rand = new Random();

    pool.add("Team 1");
    pool.add("Team 2");
    pool.add("Team 3");
    pool.add("Team 4");
    pool.add("Team 5");
    pool.add("Team 6");
    pool.add("Team 7");
    pool.add("Team 8");

    int firstTeam = rand.nextInt(8);
    int secondTeam = rand.nextInt(8);

    while(firstTeam == secondTeam){
    secondTeam = rand.nextInt(8);
    }
    System.out.println(pool.get(firstTeam) + " versus " + pool.get(secondTeam) + "!");
    }

    You should stop asking for people to write programs for you and instead ask for specific parts of the program you need help on.

    Additionally, I'm writing this off exactly what you said. Does it only need to pair up one set of teams like it does now, or should it set up all four?
    Rand al'Thor
    Rand al'Thor
    VIP
    VIP


    Posts : 6244
    Join date : 2012-01-02
    Age : 27
    Location : The Threefold Land

    Dices Rolls
    Dice Roll:

    need help with coding again... Empty Re: need help with coding again...

    Post by Rand al'Thor 2014-03-28, 23:30

    Allen's Slave wrote:
    Code:
    Random rand = new Random();
    fuk u 2??
    avatar
    peasant
    Highroller
    Highroller


    Posts : 590
    Join date : 2011-06-20
    Age : 27

    Dices Rolls
    Dice Roll:

    need help with coding again... Empty Re: need help with coding again...

    Post by peasant 2014-03-28, 23:42

    yeah tom I know I shouldn't be asking people for the code in its entirety. This is my first year in coding and I'm not particularly interested in the topic. The code is fine but we haven't learned how to use "pool" yet so I will probably not be able to use the code. Thanks anyways!
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    need help with coding again... Empty Re: need help with coding again...

    Post by Allen's Slave 2014-03-28, 23:50

    peasant is a baws wrote:yeah tom I know I shouldn't be asking people for the code in its entirety. This is my first year in coding and I'm not particularly interested in the topic. The code is fine but we haven't learned how to use "pool" yet so I will probably not be able to use the code. Thanks anyways!

    "pool" is just the name of the ArrayList.
    avatar
    peasant
    Highroller
    Highroller


    Posts : 590
    Join date : 2011-06-20
    Age : 27

    Dices Rolls
    Dice Roll:

    need help with coding again... Empty Re: need help with coding again...

    Post by peasant 2014-03-28, 23:53

    ah well then we haven't learned ArrayList neither so that's why I didn't get the code. The code has to be rather basic. Thanks for trying once again
    avatar
    peasant
    Highroller
    Highroller


    Posts : 590
    Join date : 2011-06-20
    Age : 27

    Dices Rolls
    Dice Roll:

    need help with coding again... Empty Re: need help with coding again...

    Post by peasant 2014-03-29, 00:01

    (we've only gotten as far as arrays I believe)
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    need help with coding again... Empty Re: need help with coding again...

    Post by Allen's Slave 2014-03-29, 00:02

    Code:
    public static void pair(){
    Random rand = new Random();

    int firstTeam = rand.nextInt(8) + 1;
    int secondTeam = rand.nextInt(8) + 1;

    while(firstTeam == secondTeam){
    secondTeam = rand.nextInt(8) + 1;
    }
    System.out.println("Team " + firstTeam + " versus Team " + secondTeam + "!");
    }
    Rand al'Thor
    Rand al'Thor
    VIP
    VIP


    Posts : 6244
    Join date : 2012-01-02
    Age : 27
    Location : The Threefold Land

    Dices Rolls
    Dice Roll:

    need help with coding again... Empty Re: need help with coding again...

    Post by Rand al'Thor 2014-03-29, 00:03

    stahp sayin my name plz
    Allen's Slave
    Allen's Slave
    Member
    Member


    Posts : 4445
    Join date : 2012-08-09
    Age : 30
    Location : A$AP

    need help with coding again... Empty Re: need help with coding again...

    Post by Allen's Slave 2014-03-29, 00:07

    Rand al'Thor wrote:stahp sayin my name plz

    we ned u doe

    Sponsored content


    need help with coding again... Empty Re: need help with coding again...

    Post by Sponsored content


      Current date/time is 2024-11-18, 10:30