我创建了一个playIt方法:
public void playIt(){
System.out.println("Playing the Movie");
}
它正在运作,但我还需要包含每部电影的标题。目前它只调用该方法。我需要像这样输出: 死硬 - 播放电影
for (int i = 0; i < myMovie.length; i++) {
System.out.println("Movie " + movie1 + " Title: " + myMovie[i].getTitle() + "");
System.out.println("Movie " + movie1 + " Genre: " + myMovie[i].getGenre() + "");
System.out.println("Movie " + movie1 + " Rating: " + myMovie[i].getRating() + "");
movie1 ++;
myMovie[i].playIt();
}
答案 0 :(得分:0)
更改方法播放如下:
public void playIt(String movie){
System.out.println(movie + "-Playing the Movie");
}
调用方法时,必须发送标题值:
myMovie[i].playIt((myMovie[i].getTitle());