c 入門第十七課揹包

2021-10-08 16:07:45 字數 2234 閱讀 2544

揹包物品的獲取,新增,消耗

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace _7._24.item

}return

null;}

//新增物品

public

bool

additem

(int id)

item item =

getitem

(id)

;//如果已經存在

if(item !=

null

)else

return

true;}

//消耗物品

public

bool

removeitem

(int id)

//判斷要消耗的物品

item item =

getitem

(id);if

(item !=

null

)return

true;}

else

}//輸出物品集合

public

void

out(

) console.

writeline()

;}}}

揹包物品的屬性

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace _7._24.item

}

遊戲內物品的各種資料

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace _7._24.item

abstract

class

equipdata

:itemdata

classa:

itemdata

public

override

void

start()

}classb:

itemdata

public

override

void

start()

}classc:

itemdata

public

override

void

start()

}class

dao:

equipdata

public

override

void

start()

}}

遊戲內物品的字典庫

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace _7._24.item

return instance;}}

//物品id 物品資料

public dictionary<

int, itemdata> itemdic =

newdictionary

<

int,

itemdata

>()

;private

itemmanager()

public

itemdata

getitemdata

(int id)

else}}

}

JAVA第十七課

一 序列化與反序列化 序列化是將物件的狀態寫入特定的流中的過程 反序列化則是從特定的流中獲取資料重新構建物件的過程 二 實現序列化的步奏 1 實現serilizable介面。2 建立物件輸出流 3 呼叫writeobject 方法將物件寫入檔案 4 關閉物件輸出流 三 常見異常 notseriali...

Linux第十七課

一 squid 八爪魚單純的 不加密 埠號為3128 支援http ftp ssl等多種協議的資料快取,可以基於訪問控制列表 acl 和訪問許可權列表 arl 執行內容過濾與許可權管理功能。正向 模式 一般用於企業區域網之中,讓企業使用者統一地通過squid服務訪問網際網路資源,可以在一定程度上減少...

第十七課 模組 module和包

第十七課 模組 module和包 模組是乙個包含有一系列變數,函式,類等組成的程式組 模組是乙個檔案,模組檔案問通常已.py結尾 分類 1.內建模組 bit 2.安裝的標準庫模組 3.第三方模組,需要自己安裝 4.使用者自己編寫的模組 模組的匯入 import 語句 語法import 模組名1 as...