2016-10-09 5 views
0

私はJavaのクラス図を設計することを学んでおり、これが私の最初の試みです。それが大丈夫なら教えてください。Javaクラス図

は、ここでソースコード

public class DiceRoll1 extends JFrame implements ActionListener { 

    private JTextField txtNotation; 

    private JButton btRoll, btShuffle; 

    private List<Integer> dealtCard; 
    private History history; 
    public DiceRoll1() { 
     initComponents(); 

     dealtCard = new ArrayList<>(); 
     history = new History(); 

    } 

    public void initComponents() { 
     //designing the userform 
     setSize(400, 500); 
     setLayout(new FlowLayout()); 
     setTitle("Dice Roll"); 
     txtNotation = new JTextField("2d6"); 
     btRoll = new JButton("Roll"); 
     btShuffle = new JButton("Shuffle"); 

     txtNotation.setColumns(20); 



     getContentPane().add(txtNotation); 
     getContentPane().add(btRoll); 
     getContentPane().add(btShuffle); 

     btRoll.addActionListener(this); 
     btShuffle.addActionListener(this); 

    } 

    /** 
    * @param args the command line arguments 
    */ 
    public static void main(String[] args) { 

     new DiceRoll().setVisible(true); 

    } 

    @Override 
    public void actionPerformed(ActionEvent e) { 
     JButton source = (JButton) e.getSource(); 

     if (source.equals(btRoll)) { 

     } else if (source.equals(btShuffle)) { 

     } 
    } 

    public void displayOutput(String message) { 
     System.out.println(message); 
    } 
} 

は、ここで私はプロのVisioを使用して描かれている図だだ:

enter image description here

+1

MagicDrawやSparx EAなどのプロのツールの評価版をダウンロードすることをお勧めします。これらのツールを使用すると、正しいUMLを簡単に作成できます。営業担当者に尋ねると、通常、制限なしでより長い評価期間が与えられます。 –

+0

@ JimLという情報をありがとう。 –

答えて

1

私はあなたのダイアグラムがあまりにも悪くはないと思われるが、私はいくつかのことを気づきました。

  1. コードとダイヤグラムであなたの属性の名前が
  2. 一貫していないあなたは、あなたがそれらを拡張または実装以外のJavaは組み込みクラスを追加する必要はありませんか、あなたはので、そうするように言われています彼らは不必要にあなたが相続のJFrameの間に接続し、あなたのクラス
  3. あなたがたActionListener間の実現の接続を描画すると、あなたのクラスを描画する必要があり、あなたの図
  4. を膨らま

Connection types of an UML-Class-Diagram

+1

プロパティの代わりに、関連付けられたクラスに対してロール名を使用することをお勧めします。 –

+0

ありがとうございます –

+0

役割の名前は何を意味していますか? @ThomasKilian –