السلام عليكم و رحمة الله و بركاته
أخواني ممكن أحد يساعدني عندي هذه الأسايمنت
و فيه تطبيق لل array list + liked list
لإأرجوا منكم التكرم يمساعدتي في هذا البرنامج و ها هو :
The program (A menu-driven system):
The user will be given a menu of applications to choose from. There are exactly size choices, each one representing a common manipulation of linked lists. As mentioned before, you can implement some of the tasks only. However, in order to pass this assignment, you will have to demonstrate your ability to do the most basic tasks such as traversing the list. In this assignment you are provided with the following classes:
1-SLL.java
2.SLL$SLLNode.java (inner class)
The following sample outputs will show how the system is expected to work. For more details on how to implement each task, please read the codes (and comments) provided thoroughly.
Choice 1: Display the nodes (5 marks)
In this task you should display a summary of how many nodes in the Course. Then show in details the name of each. See the following sample output. Note how after finishing a task the menu appears again.
Choose the option from the menu
1. Display the Nodes
2. Insert a Node
3. Delete a Node
4. Delete the First Node
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 1
SLL Nodes
ant bat cat
No. of Nodes 3
Choice 2: Insert a Node (20 marks)
In this task you are asked to insert a node into nodes that already exist. The user will be asked to enter a node element String type for this node and it must conform to a certain format. A Node element must string type. You must check the user input. Failing to validate the user input will cause marks loss. Also, the user can’t use element name that already exists. Finally, the node must be maintained in order. Meaning, cat can’t precede ant. So make sure you insert the new node in its correct position. The groups are initially sorted.
Choose the option from the menu
1. Display the Nodes
2. Insert a Node
3. Delete a Node
4. Delete the First Node
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 2
SLL Nodes
ant bat cat
No. of Nodes 3
Enter the value : cat
Node already exits try again
Choose the option from the menu
1. Display the Nodes
2. Insert a Node
3. Delete a Node
4. Delete the First Node
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 2
Enter the value : ax
To check that you have successfully inserted your node in the correct position, choose (1) from the menu again. The number of nodes should now be (4) and the new node should appear in the summary in its correct position.
7. Enter 0 or greater than 6 to Quit
Your Choice: 1
SLL Nodes after insertion
ant ax bat cat
No. of Nodes 4
Choice 3: Delete an existing node (10 marks)
In this task you will allow the user to choose a node to delete. Again you must ensure the node you want to delete exists first. There is a method used for finding a node and a method used for deleting it. This task is similar to what we discuss in the SLL lecture notes.
Choose the option from the menu
1. Display the Nodes
2. Insert a Node
3. Delete a Node
4. Delete the First Node
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 3
SLL Nodes after insertion
ant ax bat cat
No. of Nodes 4
Enter the value : aty
No node exits!
Choice 4: Delete the first node (5 marks)
In this task you are going to delete the first node. Again you must ensure the node exists or not. This task is similar to what we discuss in the SLL lecture notes
4. Delete the First Node
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 4
SLL Nodes after first node deletion
ax bat cat
No. of Nodes 3
Choice 5: Delete the Second node (5 marks)
In this task you are going to delete the second node. Again you must ensure that atleast two nodes exist or not. This task is similar to what we discuss in the SLL lecture notes
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 5
SLL Nodes after second node deletion
ax cat
No. of Nodes 2
Choice 6: Swap first and second Node (5 marks)
In this task you are going to swap first and second node. Again you must ensure that atleast two nodes exist or not. This task is similar to what we discuss in the SLL lecture notes
5. Delete the Second Node
6. Swap first and Second Node
7. Enter 0 or greater than 6 to Quit
Your Choice: 6
SLL Nodes
ax cat
No. of Nodes 2
SLL Nodes after swap
cat ax
No. of Nodes 2
Instructions:
1- This assignment is to be done individually. Copying the whole or part of someone else’s code will be considered cheating and will receive an academic penalty.
2- Write your name and student ID in all files at the top of each file.
3- Your work will be evaluated based on the following criteria:
a- Correctness. Your code compiles and runs without any problems and it achieves the desired output.
b- Correct implementation of all the methods.
4- Overall style and comments. Your code should be easy to read and understand and it should be well commented.
Make sure you test your program for all kinds of inputs. Testing usually helps uncover many problems with your design. You will be told how to submit your assignment later on. The due date for this assignment is Sunday (May 6, 2009). Mail to internal mail: fathirums@soharcollege or gmail: soharcollege@gmail.com
Good luck……
// SLL.java
package linkedList;
// import appropriate package
/*
* SFDV3001 - Data Structures 1
* Initial code provided by: Dr.S.Thirumurugan
*/
public class SLL{
//Declare necessary data field, refer lecture notes
//SSL$SLLNode.java
private static class SLLNode<String>{
//Declare necessary data field and constructor refer lecture notes
}
}
public SLL() {
this.first = null;
}
public static void main(String[] args) {
/*Declare necessary local variable and create three nodes
* The following three lines create a new nodes
* which contains 3 nodes with values ant, bat, cat
*/
SLL list= new SLL();
list.first = new SLLNode("ant", null);
SLLNode curr = list.first;
System.out.println("Choose the option from the menu \n 1. Display the Nodes \n 2. Insert a Node " + "\n 3. Delete a Node \n 4. Delete the First Node \n 5. Delete the Second Node\n 6. Swap first and Second Node \n 7. Enter 0 or greater than 6 to Quit");
System.out.print("Your Choice: ");
int opt = sc.nextInt();
System.out.println();
do{
switch (opt) {
case 1:
//write your code here as explained and shown in the assignment specification
case 2:
//write your code here as explained and shown in the assignment specification
case 3:
//write your code here as explained and shown in the assignment specification
case 4:
//write your code here as explained and shown in the assignment specification
case 5:
//write your code here as explained and shown in the assignment specification
case 6:
//write your code here as explained and shown in the assignment specification
default:
break;
}
System.out.println("Choose the option from the menu \n 1. Display the Nodes \n 2. Insert a Node " +"\n 3. Delete a Node \n 4. Delete the First Node \n 5. Delete the Second Node\n 6. Swap first and Second Node \n 7. Enter 0 or greater than 6 to Quit");
System.out.print("Your Choice: ");
opt = sc.nextInt();
System.out.println();
}while(opt>0 && opt <7);
}
public void printFirstToLast () {
// Print all elements in this SLL, in first-to-last order. }
public SLLNode search(String str){
return null; //dummy return statement. Please delete }
public void insert (String elem,SLLNode<String> pred) {
// Insert elem at a given point in this SLL, either after the node
// pred, or before the first node if pred is null. }
public void delete (SLLNode<String> del) {
// Delete node del from this SLL. }
public static int length(SLL list){
return count; }
public void deleteFirst () {
// Delete this SLL’s first node (assuming length > 0) }
public void deleteSecond () {
// Delete this SLL’s second node (assuming length > 1) }
public void swapFirstTwo () {
// Swap this SLL’s 1st and 2nd nodes (assuming length > 1). }
}
أنتظر ردرودكم جماعة الخير
