我有一个三个类:两个我不能碰的类——一个初始类和一个显示演示类——第三个是初始类的扩展。当演示编译时,它给了我这个错误:EssayDemo.java:16: error: method setScore in class GradedActivity cannot be applied to given types; termPaper.setScore(25.0, 18.0, 20.0, 25.0); ^required: double但是我所有的数据类型都设置为双倍,所以我不明白为什么会发生错误。我也无法更改演示代码。setScore 是在 GradedActivity 中创建的双精度值,但我也无法解决这个问题。作文课上有什么遗漏或不正确的地方?有人可以告诉我错误吗?这是导致问题的essayDemo.java: /** This program demonstrates a solution to the Essay Class programming challenge. */ public class EssayDemo { public static void main(String[] args) { // Create an Essay object. Essay termPaper = new Essay(); // Assign scores to the object. // Grammer = 25 points, Spelling = 18 points, // Length = 20 points, and Content = 25 points. termPaper.setScore(25.0, 18.0, 20.0, 25.0); // Display the score details. System.out.println("Term paper:"); System.out.println("Grammar points: " + termPaper.getGrammar()); System.out.println("Spelling points: " + termPaper.getSpelling()); System.out.println("Length points: " + termPaper.getCorrectLength()); System.out.println("Content points: " + termPaper.getContent()); System.out.println("Total points: " + termPaper.getScore()); System.out.println("Grade: " + termPaper.getGrade()); } }这是gradedActivity.java: /** The GradedActivity class stores data about a graded activity for the Essay Class programming challenge. */ public class GradedActivity { private double score; // Numeric score /** The setScore method sets the score field. @param s The value to store in score. */ public void setScore(double s) { score = s; } /** The getScore method returns the score. @return The value stored in the score field. */ public double getScore() { return score; }
添加回答
举报
0/150
提交
取消