public void updateMatrix(List bomb, List<List> getMatrixList) {
} 需求: 1.每个炸弹数据包括行、列和值信息,根据这些信息在矩阵列表中更新对应位置的值。如果值为1000,将该位置的值设置为5;如果值在10到25之间,将该位置的值设置为6;如果值在50到100之间,将该位置的值设置为7
2.假设现在打印出来的bomb=[0_1_3, 0_2_8, 0_1_9, 1_1_18,1_2_50,1_2_10,2_1_3,3_15_20],getMatrixList==
139 4 4 137 101 137
139 137 139 101 127 139
131 137 109 107 101 127
139 127 103 137 137 139
139 139 109 107 139 109
103 4 137 137 101 139
137 4 4 101 101 131
107 137 109 107 127 137
107 137 103 137 101 127
131 127 109 107 137 109
137 139 109 103 113 137
103 139 4 139 101 139
107 4 109 101 101 131
107 4 103 107 127 127
131 127 109 107 101 109
3.我会按照bomb的位置去getMatrixList里面找到然后重新跟新getMatrixList的值,bom里面是下标存储的 所以0_1_3的0是代表第一行第2列然后值是3,但是需要注意的是:getMatrixList现在有15行 相当于有三个矩阵,因为每5行相当于一个5行6列的矩阵
4.getMatrixList里面没有分子列表 就打印出来就是这样的 ,所以当 3_15_20,这个15其实是需要找到getMatrixList的倒数第五行的位置的我的3_15是只有列处理过翻倍,行是没有,我现在代码就是改怎么实现呢 中文注释帮我改一下
5.其实就是把getMatrixList划分成5行算一个矩阵,假设划分第一个数列按照下标列是012345, 那到下一个矩阵5行列就是678910,11,再往下就是12,13,14,15,16,所以3_15_20就找到15列的然后是第4行,能明白吗 ,
以下是我的代码有问题
//修改甜蜜财富1000经验球的大小中表现
public void updateMatrix(List<String> bomb, List<List<Integer>> getMatrixList) {
for (String b : bomb) {
String[] bombInfo = b.split("_");
int row = Integer.parseInt(bombInfo[0]);
int column = Integer.parseInt(bombInfo[1]);
int value = Integer.parseInt(bombInfo[2]);
// 计算实际在getMatrixList中的位置
int matrixIdx = row / 5; // 矩阵索引
int matrixRow = row % 5; // 矩阵中的行位置
int actualRow = matrixIdx * 5 + matrixRow; //实际行位置
if (value == 1000) {
getMatrixList.get(actualRow).set(column, 5);
} else if (value >= 10 && value <= 25) {
getMatrixList.get(actualRow).set(column, 6);
} else if (value > 25 && value <= 50) {
getMatrixList.get(actualRow).set(column, 7);
}
}
}