主类的UML图

时间:2017-02-26 10:58:10

标签: java uml

如何为主类制作UML图?我不知道哪个是属性和操作。我不知道哪个属性和操作是公共的还是私有的。这是代码:

public class Assignment {
    public static void main(String[] args) {
        double pi = 3.14159;
        int radius;
        Area Ar1 = new Area();
        Scanner scanner = new Scanner(System.in);

        System.out.println("Choose which shape you want to calculate; \n1 Parallelogram \n2 Circle");
        Ar1.setShape(scanner.nextInt());

        switch (Ar1.getShape()){
            case 1:
                System.out.println("Insert length");
                Ar1.setLength(scanner.nextInt());

                System.out.println("Insert width");
                Ar1.setWidth(scanner.nextInt());

                System.out.println("Area: " + Ar1.getLength() * Ar1.getWidth());
                break;

            case 2:
                System.out.println("Insert radius");
                radius = scanner.nextInt();

                System.out.println("Area: " + pi * (radius * radius));
                break;

            default:
                System.out.println("ERROR: Please choose something else");
        }
    }
}

1 个答案:

答案 0 :(得分:0)

自从我使用UML已经有一段时间了,即使我这样做,我也不是很严格。

由于该类没有属性且方法是静态的,您只需添加类名和方法名(除非您不计算UML中的静态方法)。