Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class LoadingBay {
private final int capacity;
private List<Parcel> parcels = new ArrayList<>();
LoadingBay(int capacity){
this.capacity = capacity;
}
void load(Parcel parcel){
if(!isFull()){
parcels.add(parcel);
}
}
private Boolean isFull(){
return parcels.size() == capacity;
}
Parcel unload(){
if(!isEmpty()){
return parcels.remove(parcels.size() - 1);
}
return null;
}
public boolean isEmpty() {
return parcels.isEmpty();
}
public int getParcelCount() {
return parcels.size();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment