• 结对


    结对同伴的学号姓名以及同伴的博客地址:343 卓炜杰 http://www.cnblogs.com/mxdmxdmxd78/

    结对次数 卓炜杰 容杰龙 预计编程时间(H) 结对编程时间(H) 总结
    1 编码 指导、查询资料 2 2 实现组合投功能
    2 编码、找资料 安装sql2012过程中度过  10  6 实现链接数据库
               
               

    代码例子:

     1 package Fuli;
     2 import java.sql.*;
     3 
     4  
     5 
     6 public class Main {
     7 
     8  public static void main(String [] args)
     9 
    10  {
    11 
    12   String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    13 
    14   String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=K610C-I7-D2-PC";
    15 
    16   String userName="eclipse";
    17 
    18   String userPwd="eclipse";
    19 
    20   try
    21 
    22   {
    23 
    24    Class.forName(driverName);
    25 
    26    Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
    27 
    28     System.out.println("连接数据库成功");
    29 
    30   }
    31 
    32   catch(Exception e)
    33 
    34   {
    35 
    36    e.printStackTrace();
    37 
    38    System.out.print("连接失败");
    39 
    40   }    
    41 
    42  }
    43 
    44 }
      1 package Fuli;
      2 import java.awt.event.MouseAdapter;
      3 import java.awt.event.MouseEvent;
      4 
      5 import javax.swing.Icon;
      6 import javax.swing.ImageIcon;
      7 import javax.swing.JButton;
      8 import javax.swing.JFrame;
      9 import javax.swing.JLabel;
     10 import javax.swing.JOptionPane;
     11 import javax.swing.JTextField;
     12 
     13 import org.dyno.visual.swing.layouts.Constraints;
     14 import org.dyno.visual.swing.layouts.GroupLayout;
     15 import org.dyno.visual.swing.layouts.Leading;
     16 
     17 
     18 //VS4E -- DO NOT REMOVE THIS LINE!
     19 public class PI extends JFrame {
     20 
     21     private static final long serialVersionUID = 1L;
     22     private JTextField jTextField0;
     23     private JTextField jTextField2;
     24     private JTextField jTextField3;
     25     private JTextField jTextField1;
     26     private JLabel jLabel0;
     27     private JLabel jLabel2;
     28     private JLabel jLabel3;
     29     private JLabel jLabel1;
     30     private JTextField jTextField4;
     31     private JTextField jTextField5;
     32     private JTextField jTextField6;
     33     private JLabel jLabel4;
     34     private JLabel jLabel5;
     35     private JLabel jLabel6;
     36     private JButton jButton0;
     37     private JButton jButton1;
     38     private JButton jButton2;
     39     private JButton jButton3;
     40 
     41     public PI() {
     42         initComponents();
     43     }
     44 
     45     private void initComponents() {
     46         setTitle("组合计算");
     47         setLayout(new GroupLayout());
     48         add(getJTextField0(), new Constraints(new Leading(108, 10, 10), new Leading(66, 10, 10)));
     49         add(getJTextField2(), new Constraints(new Leading(108, 38, 12, 12), new Leading(161, 10, 10)));
     50         add(getJTextField3(), new Constraints(new Leading(108, 38, 12, 12), new Leading(210, 10, 10)));
     51         add(getJTextField1(), new Constraints(new Leading(108, 38, 12, 12), new Leading(112, 10, 10)));
     52         add(getJLabel0(), new Constraints(new Leading(51, 10, 10), new Leading(68, 12, 12)));
     53         add(getJLabel2(), new Constraints(new Leading(51, 8, 12, 12), new Leading(163, 12, 12)));
     54         add(getJLabel3(), new Constraints(new Leading(51, 12, 12), new Leading(212, 12, 12)));
     55         add(getJLabel1(), new Constraints(new Leading(54, 8, 10, 10), new Leading(114, 12, 12)));
     56         add(getJTextField4(), new Constraints(new Leading(291, 38, 10, 10), new Leading(66, 12, 12)));
     57         add(getJTextField5(), new Constraints(new Leading(291, 38, 12, 12), new Leading(114, 12, 12)));
     58         add(getJTextField6(), new Constraints(new Leading(291, 38, 12, 12), new Leading(161, 12, 12)));
     59         add(getJLabel4(), new Constraints(new Leading(245, 8, 10, 10), new Leading(68, 12, 12)));
     60         add(getJLabel5(), new Constraints(new Leading(245, 8, 12, 12), new Leading(116, 12, 12)));
     61         add(getJLabel6(), new Constraints(new Leading(247, 14, 10, 10), new Leading(163, 12, 12)));
     62         add(getJButton0(), new Constraints(new Leading(472, 10, 10), new Leading(60, 12, 12)));
     63         add(getJButton1(), new Constraints(new Leading(472, 12, 12), new Leading(116, 12, 12)));
     64         add(getJButton2(), new Constraints(new Leading(472, 12, 12), new Leading(174, 10, 10)));
     65         add(getJButton3(), new Constraints(new Leading(270, 12, 12), new Leading(270, 10, 10)));
     66         setSize(610, 357);
     67     }
     68 
     69     private JButton getJButton3() {
     70         if (jButton3 == null) {
     71             jButton3 = new JButton();
     72             jButton3.setText("计算结果");
     73             jButton3.addMouseListener(new MouseAdapter() {
     74     
     75                 public void mouseClicked(MouseEvent event) {
     76                     jButton3MouseMouseClicked(event);
     77                 }
     78             });
     79         }
     80         return jButton3;
     81     }
     82 
     83     private JButton getJButton2() {
     84         if (jButton2 == null) {
     85             jButton2 = new JButton();
     86             jButton2.setText("加入定投");
     87             jButton2.addMouseListener(new MouseAdapter() {
     88     
     89                 public void mouseClicked(MouseEvent event) {
     90                     jButton2MouseMouseClicked(event);
     91                 }
     92             });
     93         }
     94         return jButton2;
     95     }
     96 
     97     private JButton getJButton1() {
     98         if (jButton1 == null) {
     99             jButton1 = new JButton();
    100             jButton1.setText("加入复利");
    101             jButton1.addMouseListener(new MouseAdapter() {
    102     
    103                 public void mouseClicked(MouseEvent event) {
    104                     jButton1MouseMouseClicked(event);
    105                 }
    106             });
    107         }
    108         return jButton1;
    109     }
    110 
    111     private JButton getJButton0() {
    112         if (jButton0 == null) {
    113             jButton0 = new JButton();
    114             jButton0.setText("加入单利");
    115             jButton0.addMouseListener(new MouseAdapter() {
    116     
    117                 public void mouseClicked(MouseEvent event) {
    118                     jButton0MouseMouseClicked(event);
    119                 }
    120             });
    121         }
    122         return jButton0;
    123     }
    124 
    125     private JLabel getJLabel6() {
    126         if (jLabel6 == null) {
    127             jLabel6 = new JLabel();
    128             jLabel6.setText("n");
    129         }
    130         return jLabel6;
    131     }
    132 
    133     private JLabel getJLabel5() {
    134         if (jLabel5 == null) {
    135             jLabel5 = new JLabel();
    136             jLabel5.setText("x");
    137         }
    138         return jLabel5;
    139     }
    140 
    141     private JLabel getJLabel4() {
    142         if (jLabel4 == null) {
    143             jLabel4 = new JLabel();
    144             jLabel4.setText("a");
    145         }
    146         return jLabel4;
    147     }
    148 
    149     private JTextField getJTextField6() {
    150         if (jTextField6 == null) {
    151             jTextField6 = new JTextField();
    152             jTextField6.setText("0     ");
    153         }
    154         return jTextField6;
    155     }
    156 
    157     private JTextField getJTextField5() {
    158         if (jTextField5 == null) {
    159             jTextField5 = new JTextField();
    160             jTextField5.setText("0     ");
    161         }
    162         return jTextField5;
    163     }
    164 
    165     private JTextField getJTextField4() {
    166         if (jTextField4 == null) {
    167             jTextField4 = new JTextField();
    168             jTextField4.setText("0     ");
    169         }
    170         return jTextField4;
    171     }
    172 
    173     private JLabel getJLabel1() {
    174         if (jLabel1 == null) {
    175             jLabel1 = new JLabel();
    176             jLabel1.setText("i");
    177         }
    178         return jLabel1;
    179     }
    180 
    181     private JLabel getJLabel3() {
    182         if (jLabel3 == null) {
    183             jLabel3 = new JLabel();
    184             jLabel3.setText("A");
    185         }
    186         return jLabel3;
    187     }
    188 
    189     private JLabel getJLabel2() {
    190         if (jLabel2 == null) {
    191             jLabel2 = new JLabel();
    192             jLabel2.setText("n");
    193         }
    194         return jLabel2;
    195     }
    196 
    197     private JLabel getJLabel0() {
    198         if (jLabel0 == null) {
    199             jLabel0 = new JLabel();
    200             jLabel0.setText("P");
    201         }
    202         return jLabel0;
    203     }
    204 
    205     private JTextField getJTextField1() {
    206         if (jTextField1 == null) {
    207             jTextField1 = new JTextField();
    208             jTextField1.setText("0     ");
    209         }
    210         return jTextField1;
    211     }
    212 
    213     private JTextField getJTextField3() {
    214         if (jTextField3 == null) {
    215             jTextField3 = new JTextField();
    216             jTextField3.setText("0     ");
    217         }
    218         return jTextField3;
    219     }
    220 
    221     private JTextField getJTextField2() {
    222         if (jTextField2 == null) {
    223             jTextField2 = new JTextField();
    224             jTextField2.setText("0     ");
    225         }
    226         return jTextField2;
    227     }
    228 
    229     private JTextField getJTextField0() {
    230         if (jTextField0 == null) {
    231             jTextField0 = new JTextField();
    232             jTextField0.setText("0         ");
    233         }
    234         return jTextField0;
    235     }
    236     
    237     double sum=0;
    238     Icon ico=new ImageIcon("./src/Fuli.png");
    239 
    240     private void jButton0MouseMouseClicked(MouseEvent event) {
    241         try
    242 {double P=Double.parseDouble(getJTextField0().getText()), 
    243 i=Double.parseDouble(getJTextField1().getText()), 
    244 n=Double.parseDouble(getJTextField2().getText()), 
    245 A=Double.parseDouble(getJTextField3().getText());
    246 double F=0;
    247 if(n>60)
    248     JOptionPane.showMessageDialog(jButton0, "超过60年限","出错", JOptionPane.INFORMATION_MESSAGE);
    249 else if(i>1)
    250     JOptionPane.showMessageDialog(jButton0, "利率应小于1","出错", JOptionPane.INFORMATION_MESSAGE);
    251 
    252 
    253 if(i==0&&P==0&&n==0&&A==0)
    254         JOptionPane.showMessageDialog(jButton0, "你没有输入任何数", "真的福利",JOptionPane.INFORMATION_MESSAGE,ico);else{
    255 F=sumofthey.F1(P, i, n, A);
    256 sum=sum+F;
    257    JOptionPane.showMessageDialog(jButton0, "F="+F,"本次计算结果", JOptionPane.INFORMATION_MESSAGE);}}catch(Exception e){JOptionPane.showMessageDialog(jButton0, "请输入数字","出错", JOptionPane.INFORMATION_MESSAGE);} 
    258     }
    259 
    260     private void jButton1MouseMouseClicked(MouseEvent event) {
    261         try
    262   {double P=Double.parseDouble(getJTextField0().getText()), 
    263             i=Double.parseDouble(getJTextField1().getText()), 
    264             n=Double.parseDouble(getJTextField2().getText()), 
    265             A=Double.parseDouble(getJTextField3().getText()), 
    266             F=0;  
    267   if(n>60)
    268         JOptionPane.showMessageDialog(jButton0, "超过60年限","出错", JOptionPane.INFORMATION_MESSAGE);
    269     else if(i>1)
    270         JOptionPane.showMessageDialog(jButton0, "利率应小于1","出错", JOptionPane.INFORMATION_MESSAGE);
    271 
    272 
    273 if(i==0&&P==0&&n==0&&A==0&&F==0)
    274         JOptionPane.showMessageDialog(jButton0, "你没有输入任何数", "真的福利",JOptionPane.INFORMATION_MESSAGE,ico);else{
    275    F=sumofthey.F2(P, i, n, A);
    276 sum=sum+F;
    277    JOptionPane.showMessageDialog(jButton0, "F="+F,"本次计算结果", JOptionPane.INFORMATION_MESSAGE);}}catch(Exception e){JOptionPane.showMessageDialog(jButton0, "请输入数字","出错", JOptionPane.INFORMATION_MESSAGE);} 
    278   
    279     }
    280 
    281     private void jButton2MouseMouseClicked(MouseEvent event) {
    282         try{
    283     double a=Double.parseDouble(getJTextField4().getText()), 
    284     x=Double.parseDouble(getJTextField5().getText()), 
    285     n=Double.parseDouble(getJTextField6().getText());
    286     if(n>60)
    287         JOptionPane.showMessageDialog(jButton0, "超过60年限","出错", JOptionPane.INFORMATION_MESSAGE);
    288     else if(x>1)
    289         JOptionPane.showMessageDialog(jButton0, "利率应小于1","出错", JOptionPane.INFORMATION_MESSAGE);
    290     
    291     double M=sumofthey.M(a, x, n);sum=sum+M;
    292     if(x==0&&n==0&&a==0)
    293         JOptionPane.showMessageDialog(jButton0, "你没有输入任何数", "真的福利",JOptionPane.INFORMATION_MESSAGE,ico);
    294     else
    295     JOptionPane.showMessageDialog(jButton0, "M="+M,"计算结果", JOptionPane.INFORMATION_MESSAGE);}
    296         catch(Exception e){JOptionPane.showMessageDialog(jButton0, "请输入数字","出错", JOptionPane.INFORMATION_MESSAGE);}
    297     }
    298 
    299     private void jButton3MouseMouseClicked(MouseEvent event) {
    300         JOptionPane.showMessageDialog(jButton0, "SUM="+sum,"计算结果", JOptionPane.INFORMATION_MESSAGE);
    301     }
    302 }

    截图显示结果:1.单利测试:                                             

           

    2.组合投资:

     

    3.数据库连接:

    详细代码地址https://github.com/IAMWicker/New-6.0.git

    收获到和感悟:两个人合作的效率的确胜过两个人分开做,这次我主要做提醒、分析、给意见的角色,炜杰主要做编程工作。在第一次合作时效率比较高,此后由于自己安装微软的sql2012出错,弄着弄着系统就崩溃了,幸亏队友帮我重装系统,可是很多软件都要重新安装,很麻烦。所以最后的链接数据库保存数据都靠队友的鼎力支持了。所以,结对合作是一个互帮互助,互补性的过程。所以,非常感谢队友的帮助。

    工作时的照片:

  • 相关阅读:
    Linux命令(一)
    数据库SQL学习(一)
    Eclipse
    VsCode支持的markdown语法参考(一)
    常用算法Tricks(一)
    dispose方法的使用
    收藏一个链接
    我还不知道取什么名字
    NioSocket的用法
    随便乱塞塞2~
  • 原文地址:https://www.cnblogs.com/57rongjielong/p/5358005.html
Copyright © 2020-2023  润新知