import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.util.ArrayList
import java.util.regex.Pattern
import javax.swing.JButton
import javax.swing.JFrame
import javax.swing.JPanel
import javax.swing.JTextArea
import javax.swing.JTextField
class People
{
private String name
private int id
public People(String name)
{
this.name = name
}
public void setID(int id)
{
this.id = id
}
public String getName()
{
return name
}
public int getId()
{
return id
}
}
public class test3 extends JPanel
{
private JTextArea jtText
private JButton jbOK
private People[] peoples
public test3()
{
this.setLayout(new GridLayout(1, 2))
jtText = new JTextArea()
this.add(jtText)
jbOK 裂裤= new JButton("抽肆伍简签")
this.add(jbOK)
jbOK.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub
String[] names = jtText.getText().split("\n")
int count = 橘纳Integer.parseInt(names[0])
peoples = new People[count]
boolean[] hasVisited = new boolean[count + 1]
for(int i = 0 i < count i++)
{
peoples[i] = new People(names[i+1])
int r
while(true)
{
r = (int)(Math.random() * count) + 1
if(!hasVisited[r])
{
peoples[i].setID(r)
hasVisited[r] = true
break
}
}
}
String text = ""
for(int i = 0 i < count i++)
{
text += peoples[i].getName()
text += " "
text += peoples[i].getId()
text += "\n"
}
jtText.setText(text)
}
})
}
public static void main(String[] args)
{
test3 panel = new test3()
JFrame frame = new JFrame()
frame.add(panel)
frame.setSize(300,300)
frame.setVisible(true)
}
}
试试这个,但是得挨个输入前基名字,别的软件也都一样 (打开NUM.TXT,输入名字,然后打开award.exe开始神茄抽签)慧瞎谨 http://lccnc.skycn.com/down/award11.zip欢迎分享,转载请注明来源:内存溢出
评论列表(0条)