Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

linked list


Today's lab you will write a program with four classes, the first class will be the LinkedList master, the second will be the Node, third will be the data being held in the list, the Student class, and the fourth will be the driver. It will be almost identical to the lecture I showed in class last Friday and the video. This Student class will have: Two private variables int id String name (same as my example) A getName() method that returns the String name. A getId() method that will return the int id. All variables will be initialized in constructor and you don't need methods to change them. The Second class with be the Node class, it will have: Two private variables A Student Class reference Node next A setNext() method that will allow you to set the reference of the instance variable next. A getNext() method that will return the Item that next is referencing. A toString() method to print out the name and id of the student A getId() to return the id for comparison A getName to return the name for comparison The third class will be the class that holds the linked list that is made up of the Node objects. It will contain: A Node reference to the first Node object in the list. A Node reference to the last Node object in the list. A menu that calls a method that is an infinite do/while loop until the user gives -1 to exit. Inside the loop you should print a menu and then wait for user input. Methods for printing the menu: What would you like to do? Press 1 to add an item Press 2 to print the list Press 3 to search the list Press 4 to delete an item Press 5 to clear the whole list Press -1 to exit Then you will need methods for handling all the menu choices above, use a switch statement and for each case call the corresponding method. Attachments
Tags Clarifications