I am working on an assignment in java where I have Prisoner
class which have date of offence (dd-MM-yyyy) localDate format, name and years in prison. I also have Cell
class where I have to add prisoners in the cell.
I have to make a method to show which Prisoner
should be release first from the Cell
.
Unfortunately, I have no idea how to do that. I already made a method for adding the prisoners in the cell and I use HashSet but I have not idea how to calculate who should be released first.
This is my code for adding the prisoners
public Boolean addPrisoner(Prisoner prisoner) {
if (this.prisonerList.size() <= this.cellSize) {
return this.prisonerList.add(prisoner);
}
return false;
}