package mg;
public class Initiate {
public static void main(String args[]){
Node head=new Node("头节点");
Link link=new Link(head);
link.addNode("组长");
link.addNode("部门经理");
link.addNode("主管副总");
link.addNode("总经理");
link.display();
}
}
class Link{
Node head;
public Link(Node head){
this.head=head;
}
public void addNode(String nodeName){
Node node=new Node(nodeName);
Node p=head;
while(true){
if(p.getNext()==null){
p.setNext(node);
break;
}
p=p.getNext();
}
}
public void display(){
Node p=head.getNext();
System.out.println("审批流程");
while(p!=null){
System.out.print(p.getName()+"-->");
p=p.getNext();
}
System.out.println("审批完成");
}
}
class Node{
private String name;
private Node next;
public Node (String name){
this.name=name;
next=null;
System.out.println("生成节点:"+name);
}
public String getName(){
return this.name;
}
public void setNext(Node next){
this.next=next;
}
public Node getNext(){
return this.next;
}
}
请帮注释一下好吗?太多,看不懂