使用错误查找器插件,我发现了这个错误,但不明白为什么它被视为代码中的错误。有人知道这些并给我适当的解释吗?谢谢。
源代码 - https://drive.google.com/open?id=1gAyHFcdHBShV-9oC5G7GeOtCGf7bXoso;
Patient.java:17 Patient.generatePriority() 使用 Random 的 nextDouble 方法生成随机整数;使用 nextInt 更有效 [Of Concern(18), Normal confidence]
public int generatePriority(){
Random random = new Random();
int n = 5;
return (int)(random.nextDouble()*n);
}
ExamRoom.java:25 ExamRoom 定义 equals 并使用 Object.hashCode() [Of Concern(16), Normal confidence]
public boolean equals(ExaminationRoom room){
if (this.getWaitingPatients().size() == room.getWaitingPatients().size()){
return true;
}
else {
return false;
}
}
ExamRoom.java:15 ExamRoom 定义 compareTo(ExaminationRoom) 并使用 Object.equals() [Of Concern(16), Normal confidence]
// Compares sizes of waiting lists
@Override
public int compareTo(ExaminationRoom o) {
if (this.getWaitingPatients().size() > o.getWaitingPatients().size()){
return 1;
}
else if (this.getWaitingPatients().size() < o.getWaitingPatients().size()){
return -1;
}
return 0;
}
Hospital.java:41 错误的月份值 12 传递给 Hospital.initializeHospital() 中的新 java.util.GregorianCalendar(int, int, int) [可怕(7),正常信心]
doctors.add(new Doctor("Hermione", "Granger", new GregorianCalendar(1988, 12, 10), Specialty.PSY, room102));
Person.java:29 在 Person.getFullName() 中忽略 String.toLowerCase() 的返回值 [最可怕的 (3),高置信度]
public String getFullName(){
firstName.toLowerCase();
Character.toUpperCase(firstName.charAt(0));
lastName.toLowerCase();
Character.toUpperCase(lastName.charAt(0));
return firstName + " " + lastName;
}