第二次結對編程作業


第二次結對編程作業

作業博客鏈接https://www.cnblogs.com/swh1148318751/p/11679697.html

同學博客鏈接 https://www.cnblogs.com/venb/p/11672891.html

fork倉庫地址:https://github.com/venbbb/ThirteenWater

我的倉庫地址:https://github.com/suweihuan079243/UI.git

分工

  陳文彬 負責出牌ai的設計編程

  蘇偉歡 負責ui的設計編程(其實沒有)。

 

UI

鏈接: https://pan.baidu.com/s/16Mk_pd572VO1kvn9OqviBQ 提取碼: fy58 

PSP表格

PSP2.1

Personal Software Process Stages

預估耗時(分鍾)

實際耗時(分鍾)

Planning

計划

 20

20

· Estimate

· 估計這個任務需要多少時間

 10

10

Development

開發

 1000

 1200

· Analysis

· 需求分析 (包括學習新技術)

 500

 600

· Design Spec

· 生成設計文檔

 20

 20

· Design Review

· 設計復審

 20

 20

· Coding Standard

· 代碼規范 (為目前的開發制定合適的規范)

 10

 10

· Design

· 具體設計

360

 360

· Coding

· 具體編碼

 1000

 1200

· Code Review

· 代碼復審

 60

 60

· Test

· 測試(自我測試,修改代碼,提交修改)

 120

 240

Reporting

報告

 60

 60

· Test Repor

· 測試報告

 20

 20

· Size Measurement

· 計算工作量

 10

 10

· Postmortem & Process Improvement Plan

· 事后總結, 並提出過程改進計划

 30

 30

 

· 合計

 3240

 3860

解題思路描述與設計實現

  • 網絡接口的使用

  使用Retrofit網絡請求庫,才用異步方式發送網絡請求。參考:https://www.jianshu.com/p/a3e162261ab6

 

  • 代碼組織與內部實現設計

Algorithm類
Operation 對牌型進行判斷並出牌
Resort 對所給的牌從小到大進行排列
Dealer 發牌員類,進行發牌
Player 玩家類,進行看牌,出牌

 

Net類
Network  創建 Retrofit 實例
創建 網絡請求接口實例 並 配置網絡請求參數
NetworkTest 發送網絡請求並提交數據
LoginReponse 存儲接收登錄返回的數據
OpenReponse 存儲接收開啟戰局返回的數據
ReigisterReponse 存儲接收注冊返回的數據
SubmitReonse 存儲接收提交返回的數據
SubmitRequest 存儲向服務器發送的數據
UserDto 存儲用戶登錄信息
  • 算法的關鍵與關鍵實現部分流程圖 

    1.要對向服務器請求返回的手牌進行從小到大重新排列。

    2.通過統計單牌,雙牌,三牌,四牌的數量來進行對牌型的判斷。

    

關鍵代碼解釋

  

/**
     * 把花色去掉,統計牌型
     * a1的值為手牌中重復一次(單張牌)的牌,a2的值為手牌中重復二次(對牌)的牌,
     * a3的值為手牌中重復三次(三張)的牌,a4的值為手牌中重復四次(炸彈)的牌。
     */

public void countPoker(ArrayList<String> handPoker)
    {
        countColor(handPoker);
        for(String str : handPoker){
            str = str.substring(1);
            numList.add(str);
        }
        int index = 0;
        while (true) {
            if ( index < numList.size() - 3 && numList.get(index).equals(numList.get(index + 3)) ) {
                a4.append(numList.get(index));
                index = index + 4;
            } else if (index < numList.size() - 2 && numList.get(index).equals(numList.get(index + 2))) {
                a3.append(numList.get(index));
                index = index + 3;
            } else if (index < numList.size() - 1 && numList.get(index).equals(numList.get(index + 1))) {
                a2.append(numList.get(index));
                index = index + 2;
            } else {
                a1.append(numList.get(index));
                index = index + 1;
            }
            if (index >= 13) break;
        }    

 

性能分析與改進

  存在的問題:  

    1.后墩有時候小於中墩  如 后墩10 10 10  6 6 ,中墩A A A 5 5

    2.只能從散排中判斷順子的滿足條件,不能拆牌。

  改進思路:

    1.對每種牌型賦予一個價值,來判斷后墩和中墩的大小問題。

    2.暫時沒有思路。

  性能分析圖:

單元測試

package game;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

class outTest {

    @Test
    void resort() {
        String str = "&K &6 $J &10 *2 &2 $A *6 *K #3 *10 #K #2";
        ArrayList<String> test = new ArrayList<>();
        test = out.resort(str);
        ArrayList<String> result = new ArrayList<>();
        assertEquals("[*2, &2, #2, #3, &6, *6, &¥, *¥, $J, &K, *K, #K, $A]",test.toString());
    }
}

 

測試Resort函數

Github的代碼簽入記錄

 

 

 

 遇到的代碼模塊異常或結對困難及解決方法

  • 問題描述:不知道UI設計應該用寫什么比較好;不知道要怎么用API, 申請網絡請求。
  • 做過哪些嘗試:pygame,javafx,web; OKhttp,HttpURLConnection,Retrofit。
  • 是否解決:是。
  • 有何收獲:學會怎么使用API,申請網絡請求。了解了UI界面的編寫。

評價你的隊友

  • 值得學習的地方:認真負責
  • 需要改進的地方:太完美了。

學習進度條

  

第N周

新增代碼(行)

累計代碼(行)

本周學習耗時(小時)

累計學習耗時(小時)

重要成長

1

300

300

20

20

熟悉規則,設計算法

2

400

700

18

38

完善算法,解決細節問題

3

 800

 1500

 25

 63

 掌握Retrofit發送網絡請求


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM