私は配列の静的フィールドで以下にリストされている次のクラスを持っています。コンストラクターを作成してすべての配列を初期化し、それを public static void BookInfo メソッドに渡す方法を教えてください/説明してください。どんな助けでも大歓迎です!
public class BookInfo {
// Global arrays accessible by all methods
public static String[] isbnInfo = {
"978-0060014018",
"978-0449221431",
"978-0545132060",
"978-0312474881",
"978-0547745527"
};
public static String[] bookTitleInfo = {
"The Greatest Stories",
"The Novel",
"Smile",
"The Bedford Introduction to Drama",
"AWOL on the Appalachian Trail"
};
public static String[] authorInfo = {
"Rick Beyer",
"James A. Michener",
"Raina Telgemeier",
"Lee A. Jacobus",
"David Miller"
};
public static String[] publisherInfo = {
"HerperResource",
"Fawcett",
"Graphix",
"Bedford St. Martins",
"Mariner Books"
};
public static String[] dateAddedInfo = {
"05/18/2003",
"07/07/1992",
"02/01/2010",
"09/05/2008",
"11/01/2011"
};
public static int[] qtyOnHandInfo = {7, 5, 10, 2, 8};
public static double[] wholesaleInfo = {12.91, 7.99, 6.09, 54.99, 10.17};
public static double[] retailInfo = {18.99, 3.84, 4.90, 88.30, 14.95};
public static void BookInfo() {
System.out.println(" Serendipity Booksellers");
System.out.println(" Book Information\n");
for(int i = 0; i < isbnInfo.length; i++){
System.out.println("ISBN: " + isbnInfo[i]);
System.out.println("Title: " + bookTitleInfo[i]);
System.out.println("Author: " + authorInfo[i]);
System.out.println("Publisher: " + publisherInfo[i]);
System.out.println("Date Added: " + dateAddedInfo[i]);
System.out.println("Quantity-On-Hand: " + qtyOnHandInfo[i]);
System.out.println("Wholesale Cost: $ " + wholesaleInfo[i]);
System.out.println("Retail Price: $ " + retailInfo[i]);
System.out.println();
}
}
}