-3
我想做一個項目,我不知道如何找到並刪除鏈接列表中的某個節點。我的教授希望我們使用這些確切的類。如何從鏈接列表中找到並刪除某個節點。使用這些特定類的java
public class StudentList {
private StudentNode shead ;
public StudentList(){}
public void setShead(StudentNode sh)
{
shead = sh;
}
public StudentNode getShead()
{
return shead;
}
public void deleteStudentNode(StudentNode s)
{
}
public StudentNode findStudentByName(String s)
{
}
}
我不會浪費了accessor和mutator方法下一個類空間
學生類
public class Student extends Person{
private String major;
private double gpa;
public Student(){}
}
人類
public class Person {
private String name;
private String gender;
public Person(){}
public Person (String n, String g)
{
n = name;
g = gender;
}
}
編輯,尤其是圓形的是學生節點
public class StudentNode {
private Student student;
private StudentNode sptr;
private FriendList fptr;
StudentNode()
{ }
public StudentNode(Student s)
{
s = student;
}
public void setStudent(Student s)
{
student = s;
}
public Student getStudent()
{
return(student);
}
public void setSptr(StudentNode s)
{
sptr = s;
}
public StudentNode getSptr()
{
return(sptr);
}
所以你必須自己創建'StudentNode'類?你有沒有做過這方面的工作? (並告訴我們!) –
@StephenP我現在加了它 – abc123