-2
import java.util.NoSuchElementException;
/**
* VolunteerLine Interface represents the interface for the VolunteerLine Class
* The class that uses this interface uses a Queue of Volunteers to simulate queuing and dequeuing volunteers to and from the
* VolunteerLine.
* @author khandan Monshi
*
*/
public interface VolunteerLineInterface {
/**
* adds a new Volunteer to the volunteer line Queue
* @param v A Volunteer object
* @return true if volunteer is queued successfully , false if queue is full
*/
public boolean addNewVoluneer(Volunteer v);
/**
* removes volunteer from the volunteer queue line
* @return Volunteer Object
* @throws NoSuchElementException if queue is empty
*/
public Volunteer volunteerTurn() throws NoSuchElementException;
/**
* checks if there are volunteers in line
* @return true if volunteer line is empty, true otherwise
*/
public boolean volunteerLineEmpty();
/**
* Returns an array of the Volunteers in the queue
* @return an array of the volunteers in the queue
*/
public Volunteer[] toArrayVolunteer();
}
import java.util.NoSuchElementException;
public class VolunteerLine implements VolunteerLineInterface{
@Override
public boolean addNewVoluneer(Volunteer v) {
// TODO Auto-generated method stub
return false;
}
@Override
public Volunteer volunteerTurn() throws NoSuchElementException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean volunteerLineEmpty() {
// TODO Auto-generated method stub
return false;
}
@Override
public Volunteer[] toArrayVolunteer() {
// TODO Auto-generated method stub
}
}
我不是這個做的是,我還有其他的錯誤,我需要解決,但我遇到的問題是我不斷收到一個錯誤說:「類型VolunteerLine必須實現繼承的抽象方法VolunteerLineInterface.addNewVoluneer(志願者)」即使我明確已經實施。我在VolunteerLine上有一個錯誤,當我將鼠標懸停在它上面並單擊添加未實現的方法時,它仍然顯示出相同的錯誤。有什麼我做錯了嗎?口口聲聲說我必須添加未實現的方法
嘗試修復其他錯誤並回到此處。你可能只需要一個乾淨的構建。 – shmosel
我注意到您的方法名稱有一個錯字:addNewVoluneer(丟失字母't') –
對我來說編譯得很好。 –