出於某種原因,我的測試程序類不能識別我的方法類中的方法。幫幫我?我得到的錯誤,如「找不到符號法digitToBarCode(INT)」和「找不到符號法校驗碼(INT)」編譯時找不到符號方法?
import java.util.Scanner;
public class ZipCode
{
public static int checkDigit(int zip)
{
int remaining = zip;
int sum = 0;
while (remaining > 0) {
sum += remaining % 10;
remaining /= 10;
}
return 10 - (sum % 10);
}
public static String digitToBarCode(int digit) {
if (digit == 1)
{
return ":::||";
}
if (digit == 2)
{
return "::|:|";
}
if (digit == 3)
{
return "::||:";
}
if (digit == 4)
{
return ":|::|";
}
if (digit == 5)
{
return ":|:|:";
}
if (digit == 6)
{
return ":||::";
}
if (digit == 7)
{
return "|:::|";
}
if (digit == 8)
{
return "|::|:";
}
if (digit == 9)
{
return "|:|::";
}
if (digit == 0)
{
return "||:::";
}
return "";
}
}
Tester類是這裏
import java.util.Scanner;
public class ZipCodeConverter
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter a zip code: ");
int zip = input.nextInt();
int checkDigit = checkDigit(zip);
String digitPrint=digitToBarCode(checkDigit);
int specificNum1=(int)((zip/Math.pow(10, 5-1)) % 10);
String swag1=digitToBarCode(specificNum1);
int specificNum2=(int)((zip/Math.pow(10, 4-1)) % 10);
String swag2=digitToBarCode(specificNum2);
int specificNum3=(int)((zip/Math.pow(10, 3-1)) % 10);
String swag3=digitToBarCode(specificNum3);
int specificNum4=(int)((zip/Math.pow(10, 2-1)) % 10);
String swag4=digitToBarCode(specificNum4);
int specificNum5=(int)((zip/Math.pow(10, 1-1)) % 10);
String swag5=digitToBarCode(specificNum5);
String y=swag1+swag2+swag3+swag4+swag5;
System.out.println("|"+y+digitPrint+"|");
}
}