英文:
How to implement this UML class diagram in Java?
问题
我有这个 UML 类图,但是我不知道如何从中生成 Java 类。有人可以帮我吗?
英文:
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
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论