ジャバ。
基本的に、「createWarehouses」配列の戻り値に問題があります。.class expected error
if Iまたはreturn w[]
不一致return w
エラーが発生した場合:
「アレイが必要ですが、ウェアハウスが見つかりました」
を呼び出すすべてのパブリック変数に対してcreateWarehouses
。どんな助けでも大歓迎です。必要に応じて、コードもここにあります。
import javax.swing.JOptionPane;
public class WarehouseTest
{
public static void main(String args[])
{
String dataArray[][] = {{ "2200", "10", "5", "5", "200", "First Street", "Dallas", "Texas", "76000" },
{ "5550", "12.75", "2", "3", "15", "Mitchell Drive", "Arlington", "Texas", "76019" },
{ "12000", "17.5", "6", "7", "0", "Jones Blvd", "Burleson", "Texas", "76120" },
{ "7235", "22.35", "54", "80", "30", "Smith Circle", "Keller", "Texas", "75020" }};
Warehouse wArray[] = new Warehouse[4];
wArray = createWarehouses( dataArray ); //15
JOptionPane.showMessageDialog( null, purchaseItems( wArray ));
JOptionPane.showMessageDialog( null, printWarehouses( wArray ));
JOptionPane.showMessageDialog( null, printWarehouseCharge( wArray ));
}
public static Warehouse[] createWarehouses( String dataArray[][] )
{
Warehouse w[] = new Warehouse[dataArray.length];
for( int i = 0; i < w.length; i++ )
{
w[i] = new Warehouse( Double.parseDouble(dataArray[i][0]),
Double.parseDouble(dataArray[i][1]),
Integer.parseInt(dataArray[i][2]),
Integer.parseInt(dataArray[i][3]),
Integer.parseInt(dataArray[i][4]),
new Address( dataArray[i][5],
dataArray[i][6], dataArray[i][7],
Integer.parseInt( dataArray[i][8] )));
}
return w[]; // ****<--- THIS IS PROBLEM**strong text**
}
public static String printWarehouses( Warehouse w[] )
{
String printMsg = String.format("");
for( int i = 1; i < w.length; i++ )
{
printMsg += String.format(
"Square Foot Size %.2f Price Per Square Foot %s Televisions %d Computers %d Tablets %d %s",
Double.parseDouble( w[i][0] ), Double.parseDouble( w[i][1] ),
Int.parseInt( w[i][2] ), Int.parseInt( w[i][3] ), Int.parseInt( w[i] [4] ),
w[i][5].toString );
}
return printMsg;
}
public static String printWarehouseCharge( Warehouse w[] )
{
String chgMsg = String.format("");
for( int i = 1; i < w.length; i++ )
{
chgMsg += String.format( "$%,.2f\n", w[i].calculateWarehouseCharge() + w[i].calculateTax() );
}
return chgMsg;
}
public static String purchaseItems( Warehouse w[] )
{
String p[][] =
{
{"Dallas", "1", "2", "5"},
{"Arlington", "0", "0", "15"},
{"Burleson", "0", "0", "3"},
{"Keller", "10", "25", "0"},
{"Dallas", "5", "0", "0"},
{"Arlington", "0", "1", "0"},
{"Burleson", "2", "4", "0"},
{"Keller", "0", "30", "3"}
};
String msg = String.format("");
for ( int i = 0; i < w.length; i++ )
{
if ( w[i].getAddress().getCity().equals( p[i][0] ))
{
msg += String.format("%,.2f\n", w[i].purchaseTelevision( 599, Integer.parseInt( p[i][1] ))
+ w[i].purchaseComputer( 759, w[i].Integer.parseInt( p[i][2] ))
+ w[i].purchaseTablet( 239.99, w[i].Integer.parseInt( p[i][3] )));
}
return msg;
}
}
}