Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
什么是在 Java中实现类似于Roguelike的竞赛系统的好方法。
我一直在考虑让每个生物都成为其种族的子类,但我不确定这是做事的好方法。
您当然不想要子类关系。我会使用组合而不是继承。
特别是,我会上课Race
Race
public class Race { public String name; public Race(String name) { this.name = name; } }
并确保每个生物都有一个Race领域。