zoukankan      html  css  js  c++  java
  • 0406 结对编程总结

    搭档: 朱杰  学号:201406114232    

        博客园地址:http://www.cnblogs.com/alfredzhu/

    一、功能需求:

        即要追求利益,又要面对不可预知的金融投资风险, “不能把鸡蛋放在同一个篮子里”,所以有必要进行组合投资。

           通过上述计算与对比,可以帮助客户进行投资决策。 

           客户:那么能否帮我记录下一笔一笔不同类型的投资,并动态显示资金现值呢?

    二、  估计时间:1h30min

        实际用时:2h30min

        估计代码:500

        实际代码:304

        分配任务: 我:设计界面,查阅资料,令代码规范并美观

                              朱杰:设计代码并审核,单元测试减少bug

        代码地址github:  https://github.com/alfredzhu/teamwork  

    三、结对编程时的工作照:

     

    四、主要功能代码:

    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.Writer;
    import java.util.ArrayList;
    
    
    public class txtIO { 
    
    public static void main (String args[]) { 
    
    ReadDate(); 
    
    WriteDate(); 
    
    } 
    
    /** 
    * 读取数据 
     * @return 
    */ 
    public static void ReadDate() { 
        CompoundCalculator C=new CompoundCalculator();
    String url = "F:/gitfile/testgit/historydata.txt"; 
    try { 
    FileReader read = new FileReader(new File(url)); 
    StringBuffer sb = new StringBuffer(); 
    char ch[] = new char[1024]; 
    int d = read.read(ch); 
    while(d!=-1){ 
    String str = new String(ch,0,d); 
    sb.append(str); 
    d = read.read(ch); 
    } 
    C.jTextArea1.setText(sb.toString());
    System.out.print(sb.toString()); 
    } catch (FileNotFoundException e) { 
    e.printStackTrace(); 
    } catch (IOException e) { 
    e.printStackTrace(); 
    }
    } 
    
    /** 
    * 写入数据 
    */ 
    public static void WriteDate() { 
    
    try{ 
    File file = new File("F:/gitfile/testgit/historydata.txt"); 
    Writer out = null ;
    out = new FileWriter(file,true) ;
    if (file.exists()) { 
    
    file.delete(); 
    } 
    CompoundCalculator C=new CompoundCalculator();
    double P=C.P, i=C.i, F=C.F;//F:复利终值 P:本金 i:利率
    int N=C.N, M=C.M, m=C.m;//N:利率获取时间的整数倍 M:复利次数 m:月数
    int result=C.result;
    int action=C.action;
    file.createNewFile(); 
    
    
    if(action==1){
        out.write("
    "+"复利"+"
    ");
        out.write("本金:" + P + "
    " + "年利率(%):" + i + "
    "
                + "存入年限:" + N + "
    " + "年复利次数:" + M + "
    " + "复利终值:" + F
                + "
    "); 
    }
    if(action==2){
        out.write("
    "+"单利"+"
    ");
        out.write("本金:" + P + "
    " + "年利率(%):" + i + "
    "
                + "存入年限:" + N + "
    " + "复利终值:" + F + "
    "); 
    }
    if(action==3){
        out.write("
    "+"本金估算"+"
    ");
        out.write("复利终值:" + F + "
    " + "年利率(%):" + i + "
    "
                + "存入年限:" + N + "
    " + "年复利次数:" + M + "
    " + "本金:" + P
                + "
    "); 
    }
    if(action==4){
        out.write("
    "+"年限估算"+"
    ");
        out.write("本金:" + P + "
    " + "年利率(%):" + i + "
    "
                + "年复利次数:" + M + "
    " + "复利终值:" + F + "
    " + "年限:" + N
                + "
    "); 
    }
    if(action==5){
        out.write("
    "+"利率估算"+"
    ");
        out.write("本金:" + P + "
    " + "存入年限:" + N + "
    " + "年复利次数:"
                + M + "
    " + "复利终值:" + F + "
    " + "年利率(%):" + i + "
    "); 
    }
    if(action==6){
        out.write("
    "+"定期投资(年)"+"
    ");
        out.write("年投资金额:" + P + "
    " + "年利率(%):" + i + "
    "
                + "定投年数:" + N + "
    " + "终值:" + F + "
    "); 
    }
    if(action==7){
        out.write("
    "+"定期投资(月)"+"
    ");
        out.write("月投资金额:" + P + "
    " + "年利率(%):" + i + "
    "
                + "定投月数:" + m + "
    " + "终值:" + F + "
    "); 
    }
    if(action==8){
        out.write("
    "+"等额本息还款"+"
    ");
        out.write("贷款金额:" + P + "
    " + "年利率(%):" + i + "
    "
                + "年限:" + N + "
    " + "年复利次数:" + M + "
    " + "等额本息还款额:" + F
                + "
    "); 
    }
    //} 
    out.close(); 
    } catch (Exception ex) { 
    System.out.println(ex); 
    } 
    } 
    }

    运行结果截图:

    五、总结:

      初次和拍档尝试结对编程,感觉还算是比较成功。从整体上看,基本完成了任务的要求,但是在这个过程中我们也遇到一些棘手的问题。

    一开始本来是考虑到数据库去导入和导出,但是实际的使用备受阻碍,最终为了完成任务也就只能选择相对比较理解的的txt文件的保存和提

    取。编程的过程中我们有点像驾驶员和副驾驶员的关系,我比较偏向与辅助的,而我的拍档比较擅长编写程序。我就先找到适应的资料和方

    法,并把自己的想法告诉拍档参考,然后他通过代码实现,在实现过程中,我专注于看程序的格式规范,还有一些编程的错误,并提出修改

    然后尝试提出一些建议和见解。

      我觉得两个人的合作过程中,需要不断的沟通和交流。有时候也许意见会有不和,但是大家的目标还是一样的。所以需要理解和妥协,尽

    可能去完成任务,并实现较高的效率。当两个人的合作足够好的时候,我是觉得1+1>2的。在以后的结对编程中,我们还需要继续磨合,尽

    可能的提高工作效率,多做一些尝试和改进。

  • 相关阅读:
    Python服务Dokcer化并k8s部署实例
    Docker Machine
    Docker使用Portainer搭建可视化界面
    三小时攻克 Kubernetes!
    Docker使用pipework配置本地网络
    使用kubeadm安装kubernetes1.12.2版本脚本【h】
    rsync详解之exclude排除文件(转)
    linux生成指定大小的文件(转)
    chown将指定文件的拥有者改为指定的用户或组(转)
    Linux系统分析命令总结
  • 原文地址:https://www.cnblogs.com/cjh123/p/5356712.html
Copyright © 2011-2022 走看看