【发布时间】:2025-12-07 12:50:01
【问题描述】:
public class DogTriathlonParticipant {
/**
* @param args the command line arguments
*/
static {
}
public static void main(String[] args) {
{
{
private static int NUM_EVENTS;
private static int totalCumulativeScore = 0;
private final string name;
private final int obedienceScore;
private final int conformationScore;
private final int agilityScore;
private final int total;
private final double avg;
private String name;
public DogTriathlonParticipant (String name, int numEvents, int score1,
int score2, int score3)
{
{
{
{
this.name = name;
NUM_EVENTS = numEvents;
obedienceScore = score1;
conformationScore = score2;
agilityScore = score3;
total = obedienceScore + conformationScore + agilityScore;
avg = (double) total / NUM_EVENTS;
totalCumulativeScore = totalCumulativeScore + total;
{
{
{
}
}
}
{
public void display()
{
System.out.println(name + " participated in " + NUM_EVENTS + " Events and has an average score of " + avg);
System.out.println( " " + name + " has total score of " + total + " bringing the total cumlative score to " + totalCumulativeScore);
}
public class TestDogs
{
}
public static void main(String[] args)
{
{
{
DogTriathlonParticipant dog1 =
new DogTriathlonParticipant("Bowser" , 2, 85, 89,0);
dog1.display();
{
}
DogTriathlonParticipant dog2 =
new DogTriathlonParticipant("Rush", 3, 78, 72, 80);
dog2.display();
{
}
DogTriathlonParticipant dog3 =
new DogTriathlonParticipant("Ginger", 3, 90, 86, 72);
dog3.display();
}
}
}
}
它不断给我的名字和字符串以及公共空白提供错误 也许我只是需要一个新的眼光来帮助我找出错误以及为什么他们说它们是非法的 你能弄清楚你能不能也向我解释一下为什么这样我就可以知道为什么? 我正在使用 netbeans,对 java 来说还是比较新的
【问题讨论】:
-
这段代码是否在一个java页面中?您没有为自定义课程 (DogTriathlonParticipant) 创建新页面吗?
-
你不能把方法放在其他方法里面。
-
里面是哪个方法
标签: java error-handling static