我有一个真正的问题。从成绩簿课程名称开始。并有一个 setName 和 getName 工作 np。然后这本书告诉我还要添加一个讲师字符串。但我就是无法让它工作,我现在已经花了 3 天时间:\ 你能帮忙吗
import java.util.Scanner;
public class GradeBook
{
private String courseName;
private String intstructorName;
private GradeBook (String startCourseName, String startInstructorName);
courseName = startCourseName;
intructorName = startInstructorName;
}
public void GradeBook( String name ) {
courseName = name;
}
public void GradeBook( String nameValue ) {
instructorName = name;
}
public void setCourseName( String name ) {
CourseName = name;
}
public void setInstructorName( String nameValue ) {
InstructorName = name;
}
public void getCourseName( String name )
{
return courseName;
}
public void getInstructorName ( String nameValue )
{
return instructorName;
}
public void displayMessage();
{
System.out.printf( "Welcome to the grade book for\n%s!\n\n",
getCourseName() );
System.out.printf( "Your instructor for this course is\n%s!\n\n",
getinstructorName() );
}
}
这是错误
C:\Users\Tony Q\Downloads>Javac GradeBook.java
GradeBook.java:9: error: ';' expected
public GradeBook(String startCourseName, String startInstructorName)
^
GradeBook.java:11: error: <identifier> expected
instructorName = startInstructorName;
^
GradeBook.java:14: error: class, interface, or enum expected
public void GradeBook( String name ) {
^
GradeBook.java:16: error: class, interface, or enum expected
}
^
GradeBook.java:18: error: class, interface, or enum expected
public void GradeBook( String nameValue ) {
^
GradeBook.java:20: error: class, interface, or enum expected
}
^
GradeBook.java:22: error: class, interface, or enum expected
public void setCourseName( String name ) {
^
GradeBook.java:24: error: class, interface, or enum expected
}
^
GradeBook.java:26: error: class, interface, or enum expected
public void setInstructorName( String nameValue ) {
^
GradeBook.java:28: error: class, interface, or enum expected
}
^
GradeBook.java:30: error: class, interface, or enum expected
public void getCourseName( String name )
^
GradeBook.java:33: error: class, interface, or enum expected
}
^
GradeBook.java:35: error: class, interface, or enum expected
public void getInstructorName ( String nameValue )
^
GradeBook.java:38: error: class, interface, or enum expected
}
^
GradeBook.java:40: error: class, interface, or enum expected
public void displayMessage()
^
GradeBook.java:44: error: class, interface, or enum expected
System.out.printf( "Your instructor for this course is\n%s!\n\n"
,
^
GradeBook.java:46: error: class, interface, or enum expected
}
^
17 errors