我遇到了一個真正的問題。僅以Gradebook courseName開始。並有一個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
什麼問題? – tbodt
'「但我不能讓它工作」 - 並沒有告訴我們問題是什麼。 –
你做了拼寫'intstructor'。 – tbodt