简体   繁体   English

主类的UML图

[英]UML diagram for main class

How do I make a UML diagram for a main class ? 如何为主类制作UML图? I don't know which is the attribute and operation. 我不知道这是属性和操作。 I don't know which attribute and operation is public or private. 我不知道哪个属性和操作是公共的还是私有的。 This is the code: 这是代码:

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

It's been a while since I've used UML, and even when I did I wasn't very strict with it. 自从使用UML以来已经有一段时间了,即使我使用UML也不是很严格。

Since the class has no attributes and the method is static, you could just add the class name and the method name (unless you're not counting static methods in UML). 由于类没有属性并且方法是静态的,因此您可以仅添加类名称和方法名称(除非您不考虑UML中的静态方法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM