Skip to content

Account

xxr5566833 edited this page Dec 8, 2017 · 4 revisions

Account

会计类负责账单的记录和资金管理

properties:

double gold_

表示当前的资金

string[] records_ (待考虑)

表示资金流动记录

boolean protect_

是否还有保护机会,初始为true,仅有一次机会,一旦保护过,就会设置为false

Object coef

和收入支出有关的科技

functions:

void profit(double num, string cause)

gold_+=num;

同时记录下cause

修改

boolean enoughThenExpend(double num, string cause)

这个方法先看是否足够,如果够了才会扣钱并返回true,如果不够那么不扣钱并返回false

if this.isEnough(num) then this.expend(num, cause) return true

else return false ##修改

void expend(double num,string cause )

不看是否足够,直接扣除相应金钱

this.gold_ = gold_ - num

  • this.gold_ >= 0 return ;
  • this.gold_ < 0 ,调用Bank.protect(),
boolean isEnough(double num)

判断当前资金gold_是否够num的支出

double getGold()

return this.gold_

void protect(double money)

if this.protect_ then

  1. 保护金数量num满足 ①num >= moneynum % 10w = 0num是满足①②的最小值,调用this.profit(num,"保护")
  2. dispatch "PROTECT"
  3. this.protect_ = false

else "GAMEOVER"

Clone this wiki locally