Athlete クラスの国と名前の 2 つの配列の最初の要素を印刷しようとしています。また、アスリートが行った 3 回のダイビング試行 (最初はゼロに設定) をシミュレートするオブジェクトも作成する必要があります。私はOOPが初めてで、メインでこれを行う方法がわかりません...コンストラクタに関する限り。これは私がこれまでに行ったことです...
これがメインです:
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;
}
}
ヘルプとご意見をお寄せいただきありがとうございます。ところで、他のクラスもありますが、関連するatmではありません..