如何在Java中实现这个UML类图?

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

How to implement this UML class diagram in Java?

问题

我有这个 UML 类图,但是我不知道如何从中生成 Java 类。有人可以帮我吗?

英文:

如何在Java中实现这个UML类图?

I have this UML class diagram, but I don't know how to make the Java classes from it.

Can anyone help me with that?

答案1

得分: 1

在UML类图中,您可以看到从Account类中延伸出两个箭头。这两个箭头的含义是,您的SavingsAccount和CheckingAccount类是从Account父类继承而来的。因此,您必须借助Java中的extends关键字来实现这两个子类。

示例框架:

public class Account{
//成员变量和方法

}
public class SavingsAccount extends Account{
//成员变量和方法

}
public class CheckingAccount extends Account {
//成员变量和方法

}

请参考此教程以获得完整理解:链接

英文:

So in the UML class diagram you can see there are two arrows going out from the Account class. Meaning of those two arrows are your SavingsAccount and CheckingAccount classes are inheriting from the Account parent class.So you must implement those two child classes with the aid of extends keyword in Java.
Please refer this tutorial for a complete understanding

Sample skeleton:

public class Account{
//member variables and methods 

}
public class SavingsAccount extends Account{
//member variables and methods

}
public class CheckingAccount extends Account {
//member variables and methods

}

huangapple
  • 本文由 发表于 2020年10月9日 16:34:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/64276578.html
匿名

发表评论

匿名网友

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

确定