Java??????????????
?????????????????? ???????[ 2017/7/12 11:29:05 ] ??????????????????? Java ?????
??????????????????????θ???????????
??????????壬?????????????????????а??????????????????????????????????????????????
??????ü?????????????????????Щ??????????????????е????????????????????????????????????????????
???????????????????????????????£?
???????
?????????????????????????????????
?????????????????????????μ????
???????
????????????????г??????С????????????????????ú????
?????????????????????????????????????????????????????????????????????ɡ??????????????????????????????????????????????????????ɡ?????????kill??????....
?????????е??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????θ?????
????????????????????????????????????????????????????
????public abstract class Chiji {
???? String name = "Unknown Player";
???? Map<String ?? String> weaponList;
???? public abstract String getName();
???? public abstract Map<String ?? String> getWeaponList();
????}
?????????????????????????????????и???Chiji
????public abstract class WeaponDecorator extends Chiji{
???? //????????
???? String weaponName;
???? //????????
???? String description;
???? //??????????????????????б???????
???? public abstract void foundWeapon();
????}
???????????????????????????????????????????????
public class ZhangSan extends Chiji {
???? public ZhangSan() {
???? name = "????";
???? weaponList = new HashMap<>();
???? //????????????????????????????????е???
???? // weaponList.put("??"??"???????");
???? // weaponList.put("Command"??"whosyourdaddy");
???? }
???? @Override
???? public String getName() {
???? return name;
???? }
???? //??????????????????????????????
???? @Override
???? public Map<String?? String> getWeaponList() {
???? return weaponList;
???? }
????}
???????????????????????????????WeaponDecorator??
????public class Dagger extends WeaponDecorator {
???? private Chiji chiji;
???? //??????????????ó?????????????????????????????
???? public Dagger(Chiji chiji) {
???? this.chiji = chiji;
???? weaponName = "???";
???? description = "??????????????";
???? }
???? @Override
???? public String getName() {
???? return chiji.getName();
???? }
???? @Override
???? public Map<String?? String> getWeaponList() {
???? foundWeapon();
???? return weaponList;
???? }
???? @Override
???? public void foundWeapon() {
???? weaponList = chiji.getWeaponList();
???? weaponList.put(weaponName??description);
???? }
????}
????getWeaponList()???????????????????????????????????????????????????????????μ????
????????????????????ɡ????????????????????????????????????????
????public class NewGame {
???? public static void main(String[] args) {
???? Chiji zhangsan = new ZhangSan();
???? //????????
???? zhangsan = new Dagger(zhangsan);
???? zhangsan = new Gun(zhangsan);
???? Map<String??String> map = zhangsan.getWeaponList();
???? for (Map.Entry<String??String> m : map.entrySet()){
???? System.out.println("??????"+m.getKey() +"-----" + "????:"+m.getValue());
???? }
???? System.out.print(zhangsan.getName()+"???");
???? }
????}
??????????????????????????????????????
??public class NewGame {
???? public static void main(String[] args) {
???? //??????????????????????????????ε??????????????????
???? Chiji zhangsan = new Gun(
???? new Dagger(
???? new ZhangSan()));
???? Map<String?? String> map = zhangsan.getWeaponList();
???? for (Map.Entry<String?? String> m : map.entrySet()) {
???? System.out.println("??????" + m.getKey() + "-----" + "????:" + m.getValue());
???? }
???? System.out.print(zhangsan.getName() + "???");
???? }
????}
????????????
?????????????????????????????????????????????
????java??IO?????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11