So I have to take a step back. I can't use a Priority Queue for my customers. My professor said not to. I'll just use a LinkedList Queue for the customer line.
Do I still need the comparable and compareTo methods now that I'm not using the priorityQueue?
So now, I've gotten this for my registers:
import java.util.LinkedList;
import java.util.Queue;
public class Register implements Comparable<Register> {
private boolean open; // line open or not?
private Queue<Customer> line; //the line of customers
public Register(){
open = true;
line = new LinkedList<Customer>();
}
public double getTotalEnqueue(){
double totalTime = 0;
for(Customer cust: line ){
totalTime += cust.getServiceTime();
}
return totalTime;
}
public void addCustomer(Customer c){
line.add(c);
}
public Customer pollCustomer(){
return line.poll();
}
public boolean isOpen(){
return open;
}
@Override
public int compareTo(Register reg) {
if(this.isOpen() && !reg.isOpen()){
return 1;
} else if (!this.isOpen() && reg.isOpen()){
return -1;
} else if(this.isOpen() && reg.isOpen()){
if (this.lineSize() > reg.lineSize()){
return -1;
} else return 1;
}
else return 1;
}
public int lineSize(){
return line.size();
}
}