我不断从编译器收到此消息,这是我的代码,它应该打印一个人姓,电话号码和生日。我应该使用类Contact节点来使程序正常工作,但我真的不明白它是如何工作的。这部分应该在联系节点之前,但由于某种原因我不能将它粘贴在输入代码行上: "
import java.util.Scanner;
public class ContactList {
public static void main(String [] args){
Scanner scnr = new Scanner(System.in);
String fullName;
String phoneNumber;
String birthDay;
ContactNode contactEntry1;
ContactNode contactEntry2;
ContactNode contactEntry3;
ContactNode currContactEntry;
System.out.println("Person 1");
System.out.println("Enter name:");
fullName = scnr.nextLine();
System.out.println("Enter phone number:");
phoneNumber = scnr.nextLine();
System.out.println("Enter birthday:");
birthDay = scnr.nextLine();
System.out.println("You entered: " + fullName + ", " + phoneNumber + ", " + birthDay);
//First contact node (head of list)
contactEntry1 = new ContactNode(fullName, phoneNumber, birthDay);
System.out.println("");
System.out.println("Person 2");
System.out.println("Enter name:");
fullName = scnr.nextLine();
System.out.println("Enter phone number:");
phoneNumber = scnr.nextLine();
System.out.println("Enter birthday: ");
birthDay = scnr.nextLine();
System.out.println("You entered: " + fullName + ", " + phoneNumber + ", " + birthDay);
contactEntry2 = new ContactNode(fullName, phoneNumber , birthDay);
contactEntry1.insertAfter(contactEntry2);
System.out.println("");
System.out.println("Person 3");
System.out.println("Enter name:");
fullName = scnr.nextLine();
System.out.println("Enter phone number:");
phoneNumber = scnr.nextLine();
System.out.println("Enter birthday:");
birthDay = scnr.nextLine();
System.out.println("You entered: " + fullName + ", " + phoneNumber);
contactEntry3 = new ContactNode(fullName, phoneNumber);
contactEntry2.insertAfter(contactEntry3);
System.out.println("");
System.out.println("CONTACT LIST");
currContactEntry = contactEntry1;
while (currContactEntry != null) {
currContactEntry.printContactNode();
currContactEntry = currContactEntry.getNext();
System.out.println("");
}
return;
}
}
/tmp/java_abImvG/ContactList.java:10: error: cannot find symbol
ContactNode contactEntry1;
^
symbol: class ContactNode
location: class ContactList
/tmp/java_abImvG/ContactList.java:11: error: cannot find symbol
ContactNode contactEntry2;
^
symbol: class ContactNode
location: class ContactList
/tmp/java_abImvG/ContactList.java:12: error: cannot find symbol
ContactNode contactEntry3;
^
symbol: class ContactNode
location: class ContactList
/tmp/java_abImvG/ContactList.java:13: error: cannot find symbol
ContactNode currContactEntry;
^
symbol: class ContactNode
location: class ContactList
/tmp/java_abImvG/ContactList.java:28: error: cannot find symbol
contactEntry1 = new ContactNode(fullName, phoneNumber, birthDay);
^
symbol: class ContactNode
location: class ContactList
/tmp/java_abImvG/ContactList.java:43: error: cannot find symbol
contactEntry2 = new ContactNode(fullName, phoneNumber , birthDay);
^
symbol: class ContactNode
location: class ContactList
/tmp/java_abImvG/ContactList.java:59: error: cannot find symbol
contactEntry3 = new ContactNode(fullName, phoneNumber);
^
symbol: class ContactNode
location: class ContactList
7 errors