Hi Guys! I'm having trouble on briefcases having the same value. for ex:
i choose briefcase 1 = 5000, briefcase 2 = 5000

how do i make the briefcases have a unique value?
Note: the value of briefcases are randomized

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DoND extends JFrame implements ActionListener{



    JButton b1=new JButton("1");

    JButton b2=new JButton("2");

    JButton b3=new JButton("3");

    JButton b4=new JButton("4");

    JButton b5=new JButton("5");

    JButton b6=new JButton("6");

    JButton b7=new JButton("7");

    JButton b8=new JButton("8");

    JButton b9=new JButton("9");

    JButton b10=new JButton("10");

    JButton nwg=new JButton("New Game");


public DoND()
{

    Container c = getContentPane();
    c.add(b1);b1.addActionListener(this);
    c.add(b2);b2.addActionListener(this);
    c.add(b3);b3.addActionListener(this);
    c.add(b4);b4.addActionListener(this);
    c.add(b5);b5.addActionListener(this);
    c.add(b6);b6.addActionListener(this);
    c.add(b7);b7.addActionListener(this);
    c.add(b8);b8.addActionListener(this);
    c.add(b9);b9.addActionListener(this);
    c.add(b10);b10.addActionListener(this);
    c.add(nwg);nwg.addActionListener(this);
    c.setLayout(new FlowLayout());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setVisible(true);
    setSize(200,300);
    setResizable(false);
}   

public void actionPerformed(ActionEvent event) {
    if (event.getSource()==b1)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b1.setText(out);

    }

    if (event.getSource()==b2)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b2.setText(out);
    }

    if (event.getSource()==b3)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b3.setText(out);
    }

    if (event.getSource()==b4)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b4.setText(out);
    }

    if (event.getSource()==b5)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b5.setText(out);
    }

    if (event.getSource()==b6)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b6.setText(out);
    }

    if (event.getSource()==b7)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b7.setText(out);
    }

    if (event.getSource()==b8)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b8.setText(out);
    }

    if (event.getSource()==b9)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b9.setText(out);
    }

    if (event.getSource()==b10)
    {
        String out;
        int val1=5000 * (int)(1+Math.random()*10);
        out=""+val1;
        b10.setText(out);
    }
    if (event.getSource()==nwg)
    {
        String a1="1",a2="2",a3="3",a4="4",a5="5",a6="6",a7="7",a8="8",a9="9",a10="10";
        b1.setText(a1);b1.setEnabled(true);
        b2.setText(a2);b2.setEnabled(true);
        b3.setText(a3);b3.setEnabled(true);
        b4.setText(a4);b4.setEnabled(true);
        b5.setText(a5);b5.setEnabled(true);
        b6.setText(a6);b6.setEnabled(true);
        b7.setText(a7);b7.setEnabled(true);
        b8.setText(a8);b8.setEnabled(true);
        b9.setText(a9);b9.setEnabled(true);
        b10.setText(a10);b10.setEnabled(true);
    }

}

    public static void main(String [] bong){
        new DoND();


    }
}

you can't ... either they are random, or the possible values are limited by already existing values (in which case, they're no longer random).

what you can do is add the already chosen values to a list. When generating a new value:

List<Integer> already; // ..

Integer newValue = getNewValue();
while(already.contains(newValue()){
  newValue = getNewValue();
}
attachToBriefcase(newValue);

Hi,
Can you please share some more details about what you are trying to achieve here.
Thanks

newcoder, the question was quite clear. what more explanation do you need?

stultuske: Sorry but I did not understand. I tried to run, the code. I could see buttons with numbers from 1 to 10 and a reset button. If you click on a button, it generates a random number. I figured out that its a game of some sort but need a little more to understand what he was trying to do.

It's a TV game show. WikiPedia has the details

ps If ever a piece of code needed to use arrays, it's this one!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.