複数の 2D 配列を検索し、配列内のデータを検索して、メソッドが呼び出されたときにメソッドに入れられるデータと比較できるようにする必要があります。私は使用しようとしましたが、検索しているすべての配列がこのタイプであることを.getClass().getSimpleName()
返すだけint[][]
なので、それらを区別するのに役立ちません。
この一連のコードを使用して、呼び出す適切な配列を決定しています。
public void tempSelection78 (int fRate, int wbTemp, int rcTons, int a, int r)
{
setTitle(TONS_05_78.getClass().getSimpleName());
for (int model = 0; model < 7; model++)
{
String tonChart = tons78FCharts[model];
for (int col = 0; col < 9; col++)
{
for (int row = 0; row < 8; row++)
{
int t = 0;
if (tonChart.equals(TONS_03_78.getClass().getSimpleName()))
{
t = TONS_03_78[col][row];
}
if (tonChart.equals(TONS_04_78.getClass().getSimpleName()))
{
t = TONS_04_78[col][row];
}
if (tonChart.equals(TONS_05_78.getClass().getSimpleName()))
{
t = TONS_05_78[col][row];
}
if (tonChart.equals(TONS_07_78.getClass().getSimpleName()))
{
t = TONS_07_78[col][row];
}
if (tonChart.equals(TONS_09_78.getClass().getSimpleName()))
{
t = TONS_09_78[col][row];
}
if (tonChart.equals(TONS_11_78.getClass().getSimpleName()))
{
t = TONS_11_78[col][row];
}
if (tonChart.equals(TONS_15_78.getClass().getSimpleName()))
{
t = TONS_15_78[col][row];
}
if (rcTons == t)
{
tableButton = new JButton(new ImageIcon(tablesFor78[model], tablesFor78[model]));
break;
}
else
{
tableButton = new JButton(new ImageIcon("CANNOT_FIND_MODEL.GIF", "SCROLL"));
}
}
}
}
for (int model = 0; model < 7; model++)
{
String flowChart = flow78FCharts[model];
for (int col = 0; col < 9; col++)
{
for (int row = 0; row < 8; row++)
{
int t = 0;
if (flowChart.equals(FLOW_03_78.getClass().getSimpleName()))
{
t = FLOW_03_78[col][row];
}
if (flowChart.equals(FLOW_04_78.getClass().getSimpleName()))
{
t = FLOW_04_78[col][row];
}
if (flowChart.equals(FLOW_05_78.getClass().getSimpleName()))
{
t = FLOW_05_78[col][row];
}
if (flowChart.equals(FLOW_07_78.getClass().getSimpleName()))
{
t = FLOW_07_78[col][row];
}
if (flowChart.equals(FLOW_09_78.getClass().getSimpleName()))
{
t = FLOW_09_78[col][row];
}
if (flowChart.equals(FLOW_11_78.getClass().getSimpleName()))
{
t = FLOW_11_78[col][row];
}
if (flowChart.equals(FLOW_15_78.getClass().getSimpleName()))
{
t = FLOW_15_78[col][row];
}
if (fRate == t)
{
tableButton = new JButton(new ImageIcon(tablesFor78[model], tablesFor78[model]));
break;
}
else
{
tableButton = new JButton(new ImageIcon("CANNOT_FIND_MODEL.GIF", "SCROLL"));
}
}
}
}
私がしたいのは、tonChart
検索可能な2次元配列を含む文字列の1つに設定することです。ただし、.getClass().getSimpleName
これ以外に設定されることはなくint[][]
、プログラムは常に、各トリプル ネスト ループの最後にある else ステートメントに迂回します。
助言がありますか?
呼び出される配列の例を次に示します。
public final int [][] TONS_03_78 =
{{27, 32, 37, 41, 45, 48, -1, -1, -1},
{-1, 41, 45, 50, 55, 59, 64, 68, 70},
{-1, 49, 55, 60, 65, 70, 75, 80, 85},
{-1, -1, 64, 70, 75, 81, 86, 91, 97},
{-1, -1, -1, 80, 86, 92, 98, 103, 109},
{-1, -1, -1, -1, 97, 103, 109, 116, 122},
{-1, -1, -1, -1, -1, 114, 122, 128, 135},
{-1, -1, -1, -1, -1, -1, -1, -1, -1}};
public final int [][] FLOW_03_78 =
{{205, 160, 137, 122, 112, 103, -1, -1, -1},
{-1, 203, 170, 150, 137, 127, 120, 113, 105},
{-1, 245, 205, 180, 163, 150, 140, 133, 127},
{-1, -1, 240, 210, 188, 173, 162, 152, 145},
{-1, -1, -1, 240, 215, 197, 183, 172, 163},
{-1, -1, -1, -1, 242, 220, 205, 193, 183},
{-1, -1, -1, -1, -1, 245, 228, 213, 202},
{-1, -1, -1, -1, -1, -1, -1, -1, -1}};