我正在尝试在我的运动员班级、国家和姓名的两个数组上打印第一个元素。我还需要创建一个对象来模拟运动员的三次潜水尝试(最初设置为零)。我是 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 ..