1、import java.util.*;import java.io.*;/运动会类public class Sports implements Serializable public String sportsdate;/举行时间 public String sportsplace;/举行地点 public String name;/运动会名称 public Player player;/该运动会所有选手 public ProgramStyle style;/该运动会的所有花样动作 public Play play;/该运动会的赛程表 public Sports(String name,Str
2、ing date,String place) sportsdate=date; sportsplace=place; this.name=name; public Sports(String name) this(name,); public Sports() this( private void setPlayerNumber(int number) if(number=player.length) return; if(number=0) player=null; return; Player temp; temp=player; player=new Playernumber; int
3、len=numbertemp.length?number:temp.length; System.arraycopy(temp,0,player,0,len); public void addPlayer(Player s) if(player=null) player=new Player1; player0=s; setPlayerNumber(player.length +1); playerplayer.length-1=s; public void deletePlayer(int index) if(index=player.length) return; for(int i=in
4、dex;i=play.length) return;play.length-1; playi=playi+1; setPlayNumber(play.length-1); private void setProgramStyleNumber(int number) if(number=style.length) return; style=null; ProgramStyle temp; temp=style; style=new ProgramStylenumber; System.arraycopy(temp,0,style,0,len); public void addProgramSt
5、yle(ProgramStyle s) if(style=null) style=new ProgramStyle1; style0=s; setProgramStyleNumber(style.length +1); stylestyle.length-1=s; public void deleteProgramStyle(int index)0|style=null|index=style.length) return;style.length-1; stylei=stylei+1; setProgramStyleNumber(style.length-1);/ScoreDlg.java/
6、修改比赛赛程项中各裁判给各选手打分的Dialog类public class ScoreDlg extends Dialog implements ActionListener Object data; Object head; Play play; JTable table; JPanel main; JScrollPane sp; public void actionPerformed( ActionEvent e ) if(e.getActionCommand().equalsIgnoreCase(取消) dispose(); else if(e.getActionCommand().eq
7、ualsIgnoreCase(添加选手 if(data=null) return; Object temp=data; data=new Objecttemp.length; for(int i=0; datai=new Objecttempi.length+1; System.arraycopy(tempi,0,datai,0,tempi.length); showTable(); show();删除选手 String no=JOptionPane.showInputDialog(请输入要删除的选手代号 if(no=null) return; data=new Objecttemp.leng
8、thtemp0.length-1; if(no.equalsIgnoreCase( System.arraycopy(tempi,0,datai,0,tempi.length-1); for(int i=1;temp0.length; if(temp0i.toString().equalsIgnoreCase(no) for(int j=0;jj+) int k; for(k=0;ki;k+) datajk=tempjk; for(k=i;tempj.length-1; datajk=tempjk+1; break;添加裁判 data=new Objecttemp.length+1temp0.
9、length; System.arraycopy(temp,0,data,0,temp.length);删除裁判请输入要删除的裁判名称 data=new Objecttemp.length-1temp0.length; System.arraycopy(temp,0,data,0,temp.length-1); if(tempi0.toString().equalsIgnoreCase(no) System.arraycopy(temp,0,data,0,i); System.arraycopy(temp,i+1,data,i,temp.length-i-1);确定 if(play=null|
10、table=null) JOptionPane.showMessageDialog(this,请确保数据不为空! int m,n; m=table.getRowCount(); n=table.getColumnCount(); play.player=null;n; String name=table.getValueAt(0,i).toString(); if(!name.equalsIgnoreCase() play.addPlayer(name); play.referee=null;m; String name=table.getValueAt(i,0).toString();) p
11、lay.addReferee(name); score=null; score=new doublem-1n-1; for(int j=1; String name=table.getValueAt(i,j).toString(); scorei-1j-1=Double.parseDouble(name); public void showTable() if(sp! main.remove(sp); if(data! head=new Objectdata0.length; head0=裁判名单;data0.length; headi=选手+(new Integer(i).toString(
12、); table=new JTable(data,head); table.setValueAt(new String(裁判选手),0,0); sp=new JScrollPane(table); main.add(sp,BorderLayout.CENTER); public ScoreDlg(Frame frame,Object d,Play p) ScoreDlg.this.dispose(); play=p; head=null; main=new JPanel(new BorderLayout(); add(main,BorderLayout.CENTER); / Box msout
13、h=Box.createHorizontalBox(); main.add(msouth,BorderLayout.SOUTH); msouth.add(Box.createHorizontalGlue(); JButton addplayer=new JButton( msouth.add(addplayer); addplayer.addActionListener(this); JButton deleteplayer=new JButton( msouth.add(deleteplayer); deleteplayer.addActionListener(this); JButton
14、addreferee=new JButton( msouth.add(addreferee); addreferee.addActionListener(this); JButton deletereferee=new JButton( msouth.add(deletereferee); deletereferee.addActionListener(this); / Box south=Box.createHorizontalBox(); add(south,BorderLayout.SOUTH); south.add(Box.createHorizontalGlue(); JButton
15、 ok=new JButton( south.add(ok); ok.addActionListener(this); JButton cancel=new JButton( south.add(cancel); cancel.addActionListener(this); this.setModal(true); this.setTitle(当前赛项的裁判给选手打分的情况/ ProgramStyle.java/花样类public class ProgramStyle implements Serializable/花样名称 public double hardfactor;/难度系数 pu
16、blic String depiction;/花样简述 public ProgramStyle(String name,double hardfactor,String depiction) this.hardfactor=hardfactor; this.depiction=depiction; public ProgramStyle(String name,double hardfactor) this(name,hardfactor, public ProgramStyle(String name) this(name,0); public ProgramStyle()/Player.j
17、ava/选手即比赛者类public class Player implements Serializable/选手名称 public int age;/年龄 public String address;/住址 public String phonenumber;/电话号码 public String no;/选手代号/选手个人简历 public Player(String no,String name,int age,String address,String phonenumber,String depiction) this.no=no; this.age=age; this.addres
18、s=address; this.phonenumber=phonenumber; public Player(String no,String name,int age) this(no,name,age, public Player(String no,String name) this(no,name,20); public Player(String no) this(no, public Player()/Play.java/比赛赛程项类public class Play implements Serializable public String program;/比赛项目名称 pub
19、lic String date;/开始日期 public String style; public String place;/比赛地点 public String player;/所参加的选手 public String referee;/所参加的裁判 public double netscore;/各裁判给各选手的打分(净得分) public Play() public Play(String name,String s) this(name,s, public Play(String name,String s,String p,String d) program=name; style=s; place=p
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1