one:
package test;
import java.util.Scanner;
public class LibraryCardGeneration {
public static void main(String[] args) {
String userName;
String password;
System.out.println("************************");
System.out.println(" Welcome to OOP Library");
System.out.println("************************");
Scanner scanner = new Scanner(System.in);
// Read user name from standard input (Task: user name cannot be empty)
System.out.print("Please set your user name: ");
userName = scanner.nextLine();
// Read user password from standard input (Task: Ask the user to re-enter the password to reconfirm)
System.out.print("Please set your password: ");
password = scanner.nextLine();
// Create a new library card
LibraryCard newCard = new LibraryCard(userName,password);
System.out.println("Your library card is generated successfully!");
運行結果顯示:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method CryptWithMD5(String) is undefined for the type LibraryCard
at test.LibraryCard.<init>(LibraryCard.java:12)
at test.LibraryCardGeneration.main(LibraryCardGeneration.java:28)作者: codedata 時間: 2015-10-28 06:51
cryptPassword = CryptWithMD5(password) 沒有定義這個方法,應該是要 cryptPassword = new CryptWithMD5(password) 吧!