Cora Dyce

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

Cora Dyce - Your personal dicing clan


    need help with coding again...

    Share

    peasant
    Highroller
    Highroller

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

    Dices Rolls
    Dice Roll:

    need help with coding again...

    Post by peasant on 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

    Cannons
    Member
    Member

    Posts : 3448
    Join date : 2012-06-28
    Age : 22

    Re: need help with coding again...

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

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

    HUNT EXP}
    avatar
    Allen's Slave
    Member
    Member

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

    Re: need help with coding again...

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

    My name is Tom.

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

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

    Re: need help with coding again...

    Post by Allen's Slave on 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?
    avatar
    Rand al'Thor
    VIP
    VIP

    Posts : 6177
    Join date : 2012-01-02
    Age : 20
    Location : The Threefold Land

    Dices Rolls
    Dice Roll:

    Re: need help with coding again...

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

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

    peasant
    Highroller
    Highroller

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

    Dices Rolls
    Dice Roll:

    Re: need help with coding again...

    Post by peasant on 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!
    avatar
    Allen's Slave
    Member
    Member

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

    Re: need help with coding again...

    Post by Allen's Slave on 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.

    peasant
    Highroller
    Highroller

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

    Dices Rolls
    Dice Roll:

    Re: need help with coding again...

    Post by peasant on 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

    peasant
    Highroller
    Highroller

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

    Dices Rolls
    Dice Roll:

    Re: need help with coding again...

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

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

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

    Re: need help with coding again...

    Post by Allen's Slave on 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 + "!");
    }
    avatar
    Rand al'Thor
    VIP
    VIP

    Posts : 6177
    Join date : 2012-01-02
    Age : 20
    Location : The Threefold Land

    Dices Rolls
    Dice Roll:

    Re: need help with coding again...

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

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

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

    Re: need help with coding again...

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

    Rand al'Thor wrote:stahp sayin my name plz

    we ned u doe

    Sponsored content

    Re: need help with coding again...

    Post by Sponsored content


      Current date/time is 2017-09-25, 20:56