我试图偷看我的队列并抓住第一个条目,这样我就可以按下删除按钮来摆脱它,但是偷看显示的是最后输入的而不是第一个。我已经尝试过 peek 和 peek front 。
private int maxSize;
private String[] queArray;
private int front;
private int rear;
private int nItems;
public String FN,LN,PN,Email,Addres,State,Zip,LicensePlate;
public Queue(String fN, String lN, String pN, String email, String address, String state, String zip,
String licensePlate) {
maxSize++;
queArray = new String[maxSize];
front = 0;
rear = -1;
nItems = 0;
FN = fN;
LN = lN;
PN = pN;
Email = email;
Addres = address;
State = state;
Zip = zip;
LicensePlate = licensePlate;
}
public void insert(String FN, String LN, String PN, String Email, String Addres, String State, String Zip,
String LicensePlate) {
String input = "{" + "First Name: "+ FN + ", " +" Last Name: "+ LN +", "+" Phone Number: "+ PN + ", " +" Email: "+ Email +", " +" Address: "+ Addres + ", " +" State: "+ State +", "+" Zip: "+ Zip + ", " +" LicensePlate: "+ LicensePlate + "}";
if (rear == maxSize - 1)
rear = -1;
queArray[++rear] = input;
nItems++;
}
public String peekFront() {
return queArray[front++];
}
public String peek() {
return queArray[front];
}
通过将 maxSize++ 更改为 maxSize = 5 来修复
温温酱
相关分类