Sure, here is the translation: Java UML 实现

huangapple go评论58阅读模式
英文:

Java UML implementation

问题

以下是您要翻译的内容:

如何在Java中实现类似的内容?

Sure, here is the translation:
Java UML 实现

目前我有这个:

public class Person {
    String name;
    String surName;
    Integer yearOfBirth;

    // 构造函数、获取器、设置器和方法
}

public class Professor extends Person {
    String department;
   
    // 构造函数、获取器、设置器和方法
}

// Professor的两个子类

public class DepartmentProfessor {
    String departmentName;

    // 构造函数、获取器、设置器和方法
}

我对UML非常新手,如果我理解正确的话,Professor必须是一个接口,DepartmentProfessors必须实现它,但是我有一个问题,Person是一个超类,有具体的方法,Professor有两个子类。

英文:

How I should make something like that in Java?

Sure, here is the translation:
Java UML 实现

Right now I've this:

public class Person {
    String name;
    String surName;
    Integer yearOfBirth;

    //Constructors, Getters, Setters and Methods
}

public class Professor extends Person {
    String department;
   
    //Constructors, Getters, Setters and Methods
}

// Two Childs of Professor

public class DepartmentProfessor {
    String departmentName;

    //Constructors, Getters, Setters and Methods
}

I'm very newbie to UML, if I understood correctly, Professor has to be an interface and DepartmentProfessors have to implement it but then I've the problem of Person being superclass, have concrete methods, of Professor and it having two subclasses.

答案1

得分: 2

你误解了。Professor 是一个简单的类,DepartmentedProfessors 也是一样。只不过后者依赖于前者(虚线箭头线所示)。这是因为 Professor 在操作 addProfessor(Professor) 的参数中被使用。

英文:

You are mistaken. Professor is a simple class and DepartmentedProfessors the same. Only that the latter depends on the first one (the dashed arrow line). This is because Professor is used in a paramter of the operation addProfessor(Professor).

huangapple
  • 本文由 发表于 2020年9月11日 17:49:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/63844674.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定