Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(PART 1) Hello, I was wondering if anyone coud help me with this JAVA program. Thank You! I know this is too big to a
(PART 1) Hello, I was wondering if anyone coud help me with this JAVA program. Thank You! I know this is too big to a single question, that's why I have split the question into two parts. LINK TO PART 2: https://www.chegg.com/homework-help/questions-and-answers/part-2-hello-wondering-anyone-coud-help-java-program-thank-know-big-single-question-s-spli-q27089657
Thank You!
The first class, Driver class will just create an instance of the Linked List class and then control the flow of the program. The Second class with be the Node class, this is where you store each individual Student's name which is your data, it will have: Two private variables (no need for a new class, just put the name in the Node class): o A String to hold the name of the student 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 of the student A getName() to return the name for comparison All names will be initialized in constructor and you don't need methods to change them, just retrieve them for printing or searching The second class will be the class that manages the linked list that is made up of the Node objects. The LinkedList Class will contain: . An instance field Node reference to the first Node object in the list. (starts null for empty list) Then you will need methods for handling all the menu choices in the driver. Note: After you get one of the print or delete methods working the traversal is the same for both of them. All items will be added to the end of the list, not the front. Clear the list is just setting the correct reference to null, very simple. all of the other methods I did on the board. The third class is the Driver, just like my example, should contain: 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 to the back of the list Press 2 to print the list Press 3 to delete an item Press 4 to clear the whole list Press -1 to exit The input from the user should go into a switch statement that switches for each input: case 1: linkedlist.addltem(node); The menu method should consistently run until the user gives a -1. The first class, Driver class will just create an instance of the Linked List class and then control the flow of the program. The Second class with be the Node class, this is where you store each individual Student's name which is your data, it will have: Two private variables (no need for a new class, just put the name in the Node class): o A String to hold the name of the student 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 of the student A getName() to return the name for comparison All names will be initialized in constructor and you don't need methods to change them, just retrieve them for printing or searching The second class will be the class that manages the linked list that is made up of the Node objects. The LinkedList Class will contain: . An instance field Node reference to the first Node object in the list. (starts null for empty list) Then you will need methods for handling all the menu choices in the driver. Note: After you get one of the print or delete methods working the traversal is the same for both of them. All items will be added to the end of the list, not the front. Clear the list is just setting the correct reference to null, very simple. all of the other methods I did on the board. The third class is the Driver, just like my example, should contain: 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 to the back of the list Press 2 to print the list Press 3 to delete an item Press 4 to clear the whole list Press -1 to exit The input from the user should go into a switch statement that switches for each input: case 1: linkedlist.addltem(node); The menu method should consistently run until the user gives a -1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started