---
# System prepended metadata

title: TPP Project

---

# TPP Project

# Project 敘述

>Deadline: 2022.6.19 23:59 (hard deadline)

每組由學號最小的成員繳交一份作業，檔名 TPP2022-HW5-ooo-ooo-ooo-ooo.rar/.zip，內含：

>src 目錄：所有程式原始碼、專案檔、資料檔 (map.dat)
>codes.pdf：可列印之程式碼文件檔（請使用附件之範本檔）

每個人都要交的心得報告 report.pdf：
>分工表與每位組員的貢獻（正常情況下應該全組一致）
>1-2 頁心得，描述在本專案中的學習心得

# 分工表
* 全員
    * 討論程式架構與介面
* 王瑞渝
    * Land class
* 陳威宇
    * Game & Map class
* 周宗翰
    * Code review & Debug
* 林廷威
    * Player class


![](https://i.imgur.com/nfkKRcM.png)


# 工作列表
1. Map & Game class
2. Player


# program flow
1. game start
2. init game core
    * read map data and set map
    * set # of player and init
3. ask player move
4. 結算行動結果
5. 檢查勝利條件
6. 結束

# class needed

1. Player
    * Attr
        * id
        * name
        * money
        * location
        * property
        * freeze
    * Member function
        * display()
        * getId()
        * getName()
        * getMoney()
        * bankrupt()
        * pay()
        * earn()
        * move()
        * addProperty()
        * arrest()
        * inJail()
        * getPos()
2. Land
    * Attr
        * id
        * name
    * Member function
        * virtual display() // name
        ![](https://i.imgur.com/EDpY59H.png)
        * virtual action(Player&) = 0 // when step on it
        ![](https://i.imgur.com/3VSLh2X.png)

    * Derive
        * Upgradable
        * Collectable
        * RandomCost
        * Jail
3. Map
    * (需要處理player位置)(=0123=那個)
    * Attr
        * units // store land
    * Member function
        * readMap
        * operator []
4. Game(core)
    * Attr
        * player list
        * map
        * turn // which player shoud move

    * member function
        * init()
        * rollDice(Player&)
        * checkBankrupt(Player&)
            ![](https://i.imgur.com/zS9v2qx.png)

        * show()
            ![](https://i.imgur.com/jyC8Lgk.png)
        * checkWin()

## Derive class
* House
    * Attr
        * price // purchase price
        * host // who own this house, pointer to player
    * Member function
        * virtual action(Player &) // buy | fine
            ```cpp=
            action(Player &p){
                if(host == nullptr){
                    buy(p);
                }
                else if(host != &p){
                    // fine(p);
                    int f = fine()
                    cout<<p.getName()<<", you must pay $"<<fine()
                        <<"to Player "<<host->getId()<<" ("<<host->getName()
                        <<")\n";
                    p.pay(f)
                    host->earn(f)
                }
                else
                {
                    // do nothing   
                    return false;
                }
                return true;       
            }
            ```

        * virtual release() = 0
        * virtual buy(Player &) = 0 // ?
        * virtual fine(Player &) = 0 // ?
* Upgradable
    * Attr
        * upgrade_price
        * fine (int array)
        * level
        * host
    * Member function
        * action(Player &) // buy | upgrade | fine
            ```cpp=
                flag f = House::action();
                if(f == false)
                   upgrade() 
            ```
        * buy() override
        * fine() override
* Collectable
    * Attr
        * baseFine
    * Member function
        * buy() 
        * fine()
* RandomCost
    * Attr
        * baseFine
    * Member function
        * buy()
        * fine()
* Jail
    * Member function
        * action() // control freeze


<!-- ![](https://i.imgur.com/ZUu1nMH.png) -->
