2016-10-09 4 views
0

자바 용 클래스 다이어그램을 디자인하는 것을 배우고 있는데 이것이 첫 번째 시도입니다. 괜찮은지 말해 줄래. 여기 자바 클래스 다이어그램

여기에 내가 Visio에서 전문 사용하여 그린 그림의 소스 코드

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); 
    } 
} 

입니다 :

enter image description here

+1

MagicDraw 또는 Sparx EA와 같은 전문 도구의 평가판을 다운로드하는 것이 좋습니다. 이러한 도구를 사용하면 올바른 UML을 쉽게 만들 수 있습니다. 영업 담당자에게 질문하면 일반적으로 제한없이 더 긴 평가 기간을 제공합니다. –

+0

@ JimL에 감사드립니다. –

답변

1

내가 다이어그램이 너무 나쁜이 아니라고 생각은하지만 몇 가지주의 . 코드와 다이어그램에서 속성

  1. 이름이 일치하지 않습니다
  2. 당신이 확장하거나 구현하거나 당신이 그렇게 때문에 할 말있어 제외하고 당신은 자바 내장 클래스를 추가 할 필요가 없습니다
  3. 그들은 불필요 당신은 상속 JFrame의 사이 연결 및 클래스
  4. 당신은 ActionListener를 사이에 실현 연결을 그려야하고 클래스를 그린다 다이어그램
  5. 을 팽창

Connection types of an UML-Class-Diagram

+1

그리고 속성 대신 관련 클래스에 역할 이름을 사용하는 것이 좋습니다. –

+0

정보 주셔서 감사합니다 –

+0

역할 이름은 무엇을 의미합니까? @ThomasKilian –