我遇到了一個問題,當用戶決定更新散列映射時,我的代碼沒有被正確更新。我的代碼的更新部分是這個散列表未被新輸入更新
if(comboBoxSelection == "Update"){
String gradeValue= (String) JOptionPane.showInputDialog(null, "Choose Grades: ", "", JOptionPane.INFORMATION_MESSAGE, null, grades, "");
String creditAmount= (String) JOptionPane.showInputDialog(null, "Choose Credit: ", "", JOptionPane.INFORMATION_MESSAGE, null, credits, "");
studentObj.courseCompleted(gradeValue.charAt(0), Integer.parseInt(creditAmount));
studentDatabase.put(iD, studentObj);
}//end update combobox selection
,並接受這些變化的方法是
public void courseCompleted(char courseGrade, int creditHours){
if (courseGrade == 'A'){
totalCredit = 4;
totalQuailtyPoints = (totalCredit * creditHours);
}//end course grade A
if(courseGrade == 'B'){
totalCredit = 3;
totalQuailtyPoints = (totalCredit * creditHours);
}//end course grade B
if(courseGrade == 'C'){
totalCredit = 2;
totalQuailtyPoints = (totalCredit * creditHours);
}//end course grade C
if(courseGrade == 'D'){
totalCredit = 1;
totalQuailtyPoints = (totalCredit * creditHours);
}//end course grade D
if(courseGrade == 'F'){
totalCredit = 0;
totalQuailtyPoints = (totalCredit * creditHours);
}//end course grade F
}//end courseCompleted method
,如果我需要發佈更多的代碼,請讓我知道