成員:郭美晴:16012109java
鄒彤:16012107git
郜碩:16012106數據庫
張文竹:16012116框架
git地址:https://gitee.com/hlxwzyyyyzyq/events佈局
第一步創建udp代碼字體
第二步數據庫鏈接this
第三步圖形界面構思3d
將三步布組合起來,一個遊戲就製做完成了orm
團隊分工:郜碩負責udp的代碼部分對象
張文竹負責數據庫的創建
鄒彤負責圖形界面的部分
郭美晴負責寫博客
我的貢獻分:
張文竹: 8
郭美晴: 10
鄒彤: 9
郜碩: 7
代碼:
遊戲代碼
import java.awt.event.MouseEvent; import java.util.Scanner; public class B { public static void main(String args[]) { Scanner in=new Scanner(System.in); //使用Scanner類定義對象 double numn[][] = new double [100][100]; double goal[] = new double [100]; double gan[] = new double [100]; double max=0,min=100; double sum=0,G=0; System.out.println("請輸入人數"); double nump=in.nextDouble(); //接收float型數據 System.out.println("請輸入遊戲次數"); double numg=in.nextDouble(); //接收float型數 for(int h=0;h<nump;h++){ goal[h]=0; gan[h]=0; } for(int s=0;s<numg;s++) { System.out.println("遊戲開始"); for(int k=0;k<nump;k++) { System.out.println("玩家輸入"); double num = in.nextDouble(); //接收float型數據 numn[s][k]=num; } for(int j=0;j<nump;j++) { sum+=numn[s][j]; } G=(sum/nump)*0.618;//求G值 double dif=0; for(int qq=0;qq<nump;qq++){//求分數 dif=Math.abs(numn[s][qq]-G); goal[qq]=dif; } for(int f=0;f<nump;f++) { if(max<goal[f]) max=goal[f]; if(min>goal[f]) min=goal[f]; } for(int th=0;th<nump;th++) { if(goal[th]==min) gan[th]=gan[th]+nump; if(goal[th]==max) gan[th]=gan[th]-2; } for(int tt=0;tt<nump;tt++) { System.out.println(gan[tt]); } } } }
登陸界面:
import java.awt.event.ActionListener; import javax.swing.JTextField; import javax.swing.JFrame; import java.awt.Color; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JLabel; import java.awt.Font; import javax.swing.JOptionPane; import javax.swing.JPasswordField; import java.awt.event.ActionEvent; public class A extends JFrame{ public JPanel pnluser; public JLabel lbluserLogIn; public JLabel lbluserName; public JLabel lbluserPWD; public JTextField txtName; public JPasswordField pwdPwd; public JButton btnSub; public JButton btnReset; public A(){ pnluser = new JPanel(); lbluserLogIn = new JLabel(); lbluserName = new JLabel(); lbluserPWD = new JLabel(); txtName = new JTextField(); pwdPwd = new JPasswordField(); btnSub = new JButton(); btnReset = new JButton(); userInit(); } public void userInit(){ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//關閉框架的同時結束程序 this.setSize(700,500);//框架長700,寬500 this.setResizable(false);//框架不能夠改變大小 this.setTitle("黃金點");//框架標題 this.pnluser.setLayout(null);//面板佈局管理 this.pnluser.setBackground(Color.pink);//面板背景顏色 this.lbluserLogIn.setText("來了老弟!");//標籤標題 this.lbluserLogIn.setFont(new Font("宋體",Font.BOLD | Font.ITALIC,25));//標籤字體 this.lbluserLogIn.setForeground(Color.blue);//標籤字體顏色 this.lbluserName.setText("帳號:"); this.lbluserPWD.setText("密 碼:"); this.btnSub.setText("登陸"); this.btnReset.setText("註冊"); this.lbluserLogIn.setBounds(300,20,200,80);//設置標籤座標及長寬高 this.lbluserName.setBounds(250,100,70,30); this.lbluserPWD.setBounds(250,150,70,30); this.txtName.setBounds(300,100,140,30); this.pwdPwd.setBounds(300,150,140,30); this.btnSub.setBounds(365,200,70,30); this.btnSub.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ btnsub_ActionEvent(e); } } ); this.btnReset.setBounds(260,200,70,30); this.btnReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ btnreset_ActionEvent(e); } } ); this.pnluser.add(lbluserLogIn); this.pnluser.add(lbluserName); this.pnluser.add(lbluserPWD); this.pnluser.add(txtName); this.pnluser.add(pwdPwd); this.pnluser.add(btnSub); this.pnluser.add(btnReset); this.add(pnluser); this.setVisible(true); } public void btnsub_ActionEvent(ActionEvent e){ String name = txtName.getText(); String pwd = String.valueOf(pwdPwd.getPassword()); if(name.equals("")){ JOptionPane.showMessageDialog(null,"請輸入帳號","錯誤",JOptionPane.ERROR_MESSAGE); return; }else if (pwd.equals("")){ JOptionPane.showMessageDialog(null,"請輸入密碼","錯誤",JOptionPane.ERROR_MESSAGE); return; }else if(true){ this.dispose(); } } public void btnreset_ActionEvent(ActionEvent e){ txtName.setText(""); pwdPwd.setText(""); } public static void main(String[] args){ new A(); } }
運行截圖:
總結:此次的實訓任務到這裏就結束了,咱們四個各司其職,雖然並無到達預期的結果,可是咱們都作到了最大的努力,並且1+1+1+1>4,只一我的的思惟是不會有太大的成果,集思廣益,團隊合做纔是最棒的