我为学生Marklits设计了JTable。我已经完成了Total,Average列。输入标记列时会自动更改。但是结果列我不知道该怎么做.Pleaase建议代码。我在这里添加了我的代码。
public Object getValueAt(int row,int column){
if (column == 5) {
Integer m1 = (Integer) getValueAt(row, 0);
Integer m2 = (Integer) getValueAt(row, 1);
Integer m3 = (Integer) getValueAt(row, 2);
Integer m4 = (Integer) getValueAt(row, 3);
Integer m5 = (Integer) getValueAt(row, 4);
if (m1 != null && m2 != null && m3 != null && m4 != null && m5 != null ) {
return m1+m2+m3+m4+m5;
} else {
return 0;
}
}
if (column == 6) {
Integer tot = (Integer) getValueAt(row, 5);
if (tot != null ) {
return tot/5;
} else {
return 0.0;
}
}
if (column == 7) {
Integer mm1 = (Integer) getValueAt(row, 0);
Integer mm2 = (Integer) getValueAt(row, 1);
Integer mm3 = (Integer) getValueAt(row, 2);
Integer mm4 = (Integer) getValueAt(row, 3);
Integer mm5 = (Integer) getValueAt(row, 4);
if (mm1 >=35 && mm2 >=35 && mm3 >=35 && mm4 >=35 && mm5 >=35 ) {
return "Pass";
} else {
return "Fail";
}
}
return super.getValueAt(row, column);
}