我有一个名为Playership
的班级和另一个名为Game
的班级。我希望Playership
课程中的Game
课程名称为播放器。我不知道该怎么做。
答案 0 :(得分:0)
你要做的是这样的事情:
Math
输出
class Playership {
public Playership() {
System.out.println("This is a playership, please be careful!");
}
}
class Game {
private Playership playership;
public Game() {
System.out.println("Starting the game...");
this.playership = new Playership();
System.out.println("I have a playership now.");
}
}
public class MyClass {
public static void main(String args[]) {
Game game = new Game();
System.out.println("The end of the Game");
}
}