我想在我的Athlete類,國家和名稱的兩個數組上打印第一個元素。我還需要創建一個模擬運動員三次潛水嘗試的對象(最初設置爲零)。我是OOP的新手,我不知道如何去做這些事情,只要我的主要工作就是這樣。這是我迄今所做的......String Java中的數組對象
這是主要的:
import java.util.Random;
import java.util.List;
public class Assignment1 {
public static void main(String[] args) {
Athlete art = new Athlete(name[0], country[0], performance[0]);
}
}
我真的我不知道該怎麼辦...
這是與類陣列。
import java.util.Random;
import java.util.List;
public class Athlete {
public String[] name = {"Art", "Dan", "Jen"};
public String[] country = {"Canada", "Germant", "USA"};
//Here i would like to create something that would be representing 3 dive attemps (that relate to dive and score. eventually.)
Athlete(String[] name, String[] country, Performance[] performance) {
this.name = name;
this.country=country;
this.performance=performance;
}
public Performance Perform(Dive dive){
dive.getDiveName();
return null;
}
public String[] getName() {
return name;
}
public void setName(String[] name) {
this.name = name;
}
public String[] getCountry() {
return country;
}
public void setCountry(String[] country) {
this.country = country;
}
}
在此先感謝您的任何幫助和意見! BTW還有其他類也一樣,只是沒有相關的ATM ..
但是,我不明白你在潛水時想做什麼。 –