Today I make a shuangse qiu double betting calculation. In fact, it is very simple to calculate the number of combinations can be. The interface design uses AWT, after the value of the list box is selected, the Itemstatechanged event is excited to process. Here is an example:
Package study;
import java.awt.*;
import java.awt.event.*;
public class SSQ extends Frame//implements ActionListener
{
label A=new label ("Please select red ball and Basketball number:");
label Sta=new label ("Thank you for using the World News Software!") Copyright by mr.zhou;firstcoffee@sina.com;oicq:5129575 ");
Panel p=new Panel ();
Panel p1=new Panel ();
TextArea ta = new TextArea ();
list H=new list (4);
list L=new list (4);
button Bn=new button ("clear");
long Tmp_count;
int tmp_r,tmp_b;
public ssq ()
{
super ("Shuangse Qiu Duplex Calculation");
setSize (500,310);
for (int i=7;i<=20;i++)
{
H.additem (string.valueof (i));
}
for (int i=1;i<=16;i++)
{
L.additem (string.valueof (i));
}
H.setbackground (Color.orange);
L.setbackground (Color.Blue);
h.select (0);
l.select (0);
P.add (a);
p.add (h);
p.add (L);
p.add (BN);
P1.add (TA);
P1.add (STA);
Add ("North", p);
Add ("Center", p1);
Addwindowlistener (New Windowadapter ()
{
public void windowclosing (WindowEvent e)
{
system.exit (0);
}
});
ta.append ("Calculated result:" + "
");
H.additemlistener (New ItemListener ()
{
public void itemstatechanged (ItemEvent e) {
Tmp_r=integer.parseint (H.getselecteditem ());
}
});
L.additemlistener (New ItemListener ()
{
public void itemstatechanged (ItemEvent E1) {
Tmp_b=integer.parseint (L.getselecteditem ());
print (tmp_r,tmp_b);
}
});
Bn.addactionlistener (New ActionListener () {
public void actionperformed (ActionEvent e)
{
Ta.settext ("Calculated result:" + "
");
}
}
);
super.setresizable (FALSE);
Show ();
}
Long Count (int x,int y)
{
long tmp_count1; FDFDFDFDFD
int a,b;
long p=1,c=1;
a=x;b=y;
for (int i=1;i<=6;i++)
{
C=c*i;
}
for (int j= (a-5); j<=a;j++)
{
p=p*j;
}
//system.out.println (P);
tmp_count1=p/c*b;
return tmp_count1;
}
void print (int x1,int y1)
{long tmp_count2;
Tmp_count2=count (x1,y1);
//system.out.println ("tmp_count2=" +tmp_count2);
ta.append (tmp_r+ "red ball Plus" +tmp_b+ "Blue Ball" + "Total Amount:" +tmp_count2*2+ "
");
}
public static void Main (String arg[])
{
new SSQ ();
}
}
************** End