2015年2月9日月曜日

開発環境

  • OS X Yosemite - Apple (OS)
  • Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
  • Java (プログラミング言語)
  • javac (コンパイラ)
  • java (application launcher)

Head First Object-Oriented Analysis and Design: A Brain Friendly Guide to OOA&D (Brett McLaughlin (著)、 Gary Pollice (著)、 David West (著) 、 O'Reilly Media)のChapter 9. Iterating and Testing: The Software is Still for the Customer、SHARPEN YOUR PENCIL(No. 5721)を解いてみる。

その他参考書籍

SHARPEN YOUR PENCIL(No. 5721)

  • Commonality
    • name
    • type
    • weapons
    • id
  • Variability
    • strength
    • speed
    • stamina
    • weapon
    • hitPoints
    • weight
    • intelligence
    • firstName
    • allegiance
    • wingspan
    • landSpeed
    • experience
    • gear
    • lastName
    • groundSpeed
    • hunger

コード(BBEdit, Emacs)

Unit.java

import java.util.Map;

public class Unit {
    private String type;
    private Map<String, Object> commonProperties;
    private Map<String, Object> properties;
    
    
    public Unit(Weapon weapon){
        
    }
    public void setType(String type){
        this.type = type;
    }
    public String getType(){
        return this.type;
    }
    public void setCommonProperty(String key, Object value){
        commonProperties.put(key, value);
    }
    public Object getCommonProperty(String key){
        return commonProperties.get(key);
    }    
    public void setProperty(String key, Object value){
        properties.put(key, value);
    }
    public Object getProperty(String key){
        return properties.get(key);
    } 
}

Weapon.java

public enum Weapon{
    Bazooka,
    Gatling
}

入出力結果(Terminal)

$ javac Unit.java
$

0 コメント:

コメントを投稿