Java Code.. Follow the instructions ..


LAB3 REQUIREMENTS

-We continue to apply Object Oriented Programming to each lab; we still have the data type class and the driver class in one project. In the data structure, an object of data type class is called as a node.

A data structure is a collection of nodes that is organized in some fashions. The data structure class not only stores nodes (insert nodes), but also supports operations for accessing and manipulating the nodes, such as, delete notes, update nodes, or display nodes.


You can read the topics relating to ArrayList and LinkedList at HOW TO DO LAB to learn how to create an ArrayList or create a LinkedList, and how to insert, delete, update, or display the nodes to these data structure types.


DATA TYPE CLASS

Class FA2022_Student_yourLastName

We are going to use objects of class FA2022_Student_yourLastName as nodes to demo all the operations of data structures in this lab.

Provide the UML and the code of the class FA2022_Student_yourLastName that will hold the information of a student: student id (String), last name (String), first name (String), phone(String), address (String), no-argument constructor, parameterized constructor, and the method toString() to display the output of one student in the following format:


Student ID: 1212121

Student name: Kevin Bellamy

Phone: 2146545676

Address: 34 GreenVille Richardson TX 75080


DRIVER CLASS

Class FA2022_Demo_JAVA_DataStructures_YourLastName.java

Provide the pseudo-code and the code of class FA2022_Demo_JAVA_DataStructures_YourLastName that helps the users to select one of the data structure types from the following menu to work on:


FA2022_Demo_JAVA_DataStructures_YourLastName.java"

JAVA Data Structures - JAMES SMITH"

----------------------------------------------------------

1.DEMO JAVA ARRAYLIST

2.DEMO JAVA LINKEDLIST

0.EXIT"

Type 1 or 2 to select data structure type or 0 to exit.


TYPE1: JAVA ARRAYLIST

ArrayList is a generic class that means it can store nodes of any data type if you do not determine the data type of nodes.

The syntax to declare a data structure of Java ArrayList type as below to store nodes of any data types:

ArrayList javaArrayList = new ArrayList();


After creating the javaArrayList then do the following tasks:


TASK1: OPERATION ADD (INSERT NODES TO THE ArrayList)

-Display the message: “TASK1: OPERATION ADD – Insert nodes to the ArrayList”

-Access the operation add of the ArrayList to insert numbers from 0 to 59 to the ArrayList created above

-Display message to ask and read from the keyboard the information to create 5 objects of class FA2022_Student_yourLastName and access the operation add to insert 5 these students to the above ArrayList

-Continue to add numbers from 65 to 99 to the above ArrayList.

TASK2: OPERATION GET (READ INFORMATION OF ONE NODE)

-Display the message: “TASK2: OPERATION GET - Read information of one node”

-Access the operation get of javaArrayList then display the node at index 50 (named it as number50)

-Access the operation get of javaArrayList then display the node at index 60 (named it as student60)

TASK3: VERIFY ENCAPSULATION (CHECK IF ArrayList IS ENCAPSULATED)

Encapsulation is the feature of a data structure to protect the information of nodes stored inside from any change performed outside the data structure

-Display the message: “VERIFY ENCAPSULATION FEATURE (ArrayList is not an encapsulated data structure)”

-get the student at index 61 of the javaArrayList and store it as student61.

-Display message and read the new address and change the address of this student61

-get the student at index 61 of the javaArrayList again and store it as inside61

-compare the address of student61 with the address of insde61.

If these addresses are different display message box: “Java ArrayList is encapsulated.” THAT MEANS CHANGING THE INFORMATION OF STUDENT OUTSIDE THE ArrayList DOES NOT AFFECT THE STUDENT INSIDE THE ArrayList WHERE BOTH STUDENTS ARE READ FROM THE SAME INDEX

Otherwise, display message box: “Java ArrayList is unencapsulated”

TASK4: OPERATION SET (UPDATE ONE NODE WITH NEW NODE)

-Display the message: “TASK4: OPERATION SET – Update information of one node”

-Read and display the node at index 62 then store it to student62

-Display the message to ask the information of one new student about student id, last name, first name, address. Then create a new object newStudent of class FA2022_Student_yourLastName

-Use the operation set at index 62 to update the newStudent at index 62

-read and display the node at index 62 then store it to updateStudent62 to confirm the difference of the updateStudent62 and student62

TASK5: CHECK THE SIZE (READ THE TOTAL NUMBER OF NODES IN ArrayList)

-Display the message: “TASK5: OPERATION SIZE – Read total number of nodes in ArrayList”

-Display the size of the javaArrayList

TASK6: OPERATION REMOVE (DELETE A NODE FROM ArrayList)

-Display the message: “TASK6: OPERATION REMOVE – Delete one node”

-Use the operation remove to delete the node at index 63

-Display the size of the javaArrayList to see the size reduced by 1 comparing with the size of task5

TYPE2: JAVA LINKEDLIST

LinkedList is also a generic class that means it can store nodes of any data type if you do not determine the data type of nodes. The syntax to declare a data structure of Java LinkedList only displaying the Student object as below:

LinkedList<Student> javaLinkedList = new LinkedList<Student>();


After creating the javaLinkedList, do the following tasks:


TASK1: OPERATION ADD (INSERT NODES TO THE LinkedList)

-Display the message: “TASK1: OPERATION ADD – Insert nodes to the LinkedList”

-Display message to ask the information of 3 students and access the operation add to insert 3 these students to javaLinkedList.

-Display message to ask the information of 1 student and access the operation addFist to insert this student to the javaLinkedList.

-Display message to ask the information of 1 student and access the operation add at index 3 this student to the javaLinkedList.


TASK2: OPERATION GET (READ INFORMATION OF ONE NODE)

-Display the message: “TASK2: OPERATION GET - Read information of nodes”

-Use the for loop and access the method get at index to get and display the information of 5 students in the javaLinkedList

-Access the operation getFirst to get and display the information of the first node in the javaLinkedList

-Access the operation getLast of to get and display the information of the last node in the javaLinkedList

TASK3: VERIFY ENCAPSULATION (CHECK IF LinkedList IS ENCAPSULATED)

Encapsulation is the feature of a data structure to protect the information of nodes stored inside from any change performed outside the data structure

-Display the message: “TASK3: VERIFY ENCAPSULATION FEATURE (LinkedList is not an encapsulated data structure)”

-get the student at index 1 of the javaLinkedList and store it as student1.

-Display message and read the new address and change the address of this student1

-get the student at index 1 of the javaLinkedList again and store it as inside1

-compare the address of student1 with the address of insde1

If these addresses are different display message box: “Java LinkedList is encapsulated.” THAT MEANS CHANGING THE INFORMATION OF STUDENT OUTSIDE THE ArrayList DOES NOT AFFECT THE STUDENT INSIDE THE ArrayList WHERE BOTH STUDENTS ARE READ FROM THE SAME INDEX

Java Code.. Follow the instructions .. 1

Otherwise, display message box: “Java LinkedList is unencapsulated”

Java Code.. Follow the instructions .. 2

TASK4: OPERATION SET (UPDATE ONE NODE WITH NEW NODE)

-Display the message: “TASK4: OPERATION SET – Update information of one node in LinkedList”

-Read and display the node at index 2 then store it to student2

-Display the message to ask the information of one new student about student id, last name, first name, address. Then create a new object newStudent of class FA2022_Student_yourLastName

-Use the operation set at index 2 to update the newStudent at index 2

-read and display the node at index 2 then store it to updateStudent2 to confirm the difference of the updateStudent2 and student2

TASK5: CHECK THE SIZE (READ THE TOTAL NUMBER OF NODES IN LinkedList)

-Display the message: “TASK5: OPERATION SIZE – Read total number of nodes in LinkedList”

-Display the size of the LinkedList

TASK6: OPERATION REMOVE (DELETE A NODE FROM LinkedList)

-Display the message: “OPERATION REMOVE – Delete one node”

-Access the operation remove to delete the node at index 3

-Access the operation removeFist to delete the first node

-Access the operation removeLast to delete the last node

-Display the size of the javaLinkedList to see the size reduced by 3 comparing with the size of task5


HOW TO TURN IN THE LAB

The pseudo-code, UML of data type class, output pictures

FA2022_Student_yourLastName.java

FA2022_Demo_JAVA_DataStructures_YourLastName.java

FA2022_Student_yourLastName.class

FA2022_Demo_JAVA_DataStructures.class

HOW TO GRADE THE LAB


Items graded

Score

COMPLETE LAB ON TIME

UML, pseudo-code, output pictures

Turn in all requested files

Data type class

Data members, 2 constructors, setAddress, getAddress, toString

2

ArrayList

Create ArrayList

1

Add numbers 0-59, 5 students, numbers 65 to 99

1.5

Display node at 50, node at 60

Verify encapsulation

Update node at 62

Check size

Remove node at 63 – check size

1.5

LinkedList

Create LinkedList

Add 3 students, add First, add last

1.5

Display 5 nodes, display first node, display last node

1.5

Verify encapsulation

Update node 2

Check size

-Remove node at index 3, remove first, remove last, check size

2

Compile success, no error, qualified to the requirement

3

Output correct format

File name at top, comments

Total

30