BasicList.java - / A+ Computer Science -...

This preview shows page 1 - 3 out of 6 pages.

The preview shows page 1 - 3 out of 6 pages.
// A+ Computer Science-//Name -//Date -//Class -//Lab-import static java.lang.System.*;public class BasicList{private ListNode front;private ListNode back;public BasicList( ){front = null;back=null;}public void add( Comparable insertItem ){if(front==null){back=new ListNode(insertItem,back);front=back;}else{ListNode rest=back;back = new ListNode( insertItem, null );rest.setNext(back);}}public int nodeCounter(ListNode node){if(node == null){return 0;}return 1 + nodeCounter(node.getNext());}public void addFirst( Comparable insertItem){
front = new ListNode( insertItem, front );if(back==null)back=front;}public void addLast(Comparable insertItem ){ListNode fail = new ListNode(insertItem,null);if(front==null){front = fail;}else{ListNode pointer = front;while(pointer.getNext()!=null){pointer = pointer.getNext();}pointer.setNext(fail);}}public Comparable remove(int index){Comparable rest = "";ListNode tester4 = front;int yeet = nodeCounter(tester4);if(index==0){rest=tester4.getValue();front=front.getNext();}else{for(int y = 1; y <= yeet; y ++){if(y%index==0){rest=tester4.getNext().getValue();if(y==yeet){rest=tester4.getNext().getValue();}tester4.setNext(tester4.getNext().getNext());

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 6 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Hyatt
Tags
Pointer, Void type, public class BasicList, public BasicList, public int nodeCounter

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture