Rlab5
COSC 2436 – LAB5
Contents TITLE .............................................................................................................................................................. 1
TIME TO COMPLETE ...................................................................................................................................... 1
COURSE OBJECTIVES – LEARNING OUTCOME .............................................................................................. 1
LAB OBJECTIVES ............................................................................................................................................ 2
SKILLS REQUIRED........................................................................................................................................... 2
HOW TO DO EACH PART ............................................................................................................................... 2
REQUIREMENT lab5 ...................................................................................................................................... 3
HOW TO TURN IN THE LAB ........................................................................................................................... 5
HOW TO GRADE THE LAB .............................................................................................................................. 5
Note: in the instruction of the lab change “yourLastName” to your last name. In the example, change
Smith to your last name, change James Smith to your full name, change Mary Lane to the name that
users type in from the keyboard (if these words are in this instruction)
TITLE
Linked List structure – Singly Linked List, Singly Linked List Iterator, Java LinkedList
TIME TO COMPLETE
Two week
COURSE OBJECTIVES – LEARNING OUTCOME
[LO1] Provide UML class diagram and the code of data type classes Provide the pseudo-code or flowchart based on the requirement of a project before writing the code of the driver class. Also, can access data members of data type classes Describe and implement the inheritance relationship between super class and child classes. Can use abstract classes or interface and apply polymorphism to the real life problem project [LO4] Define and implement Singly linked list, Circular Linked List, Double ended Singly Linked List, doubly linked list, with their operations and Java Linked List [LO11] How to evaluate the performance of each operation algorithm of data structure type based on BigO and Density
LAB OBJECTIVES
-Complete the lab on time (Time Management)
-Can write the pseudo-code -Can provide UML of data type class -Can write comments in the program -Can write the code of data type classes including data members, no-argument constructor, parameter constructors, mutator methods, assessor methods, method toString and other methods -Can apply Inheritance concept to write the code of child classes that inherits data members, constructors and other methods from parent class -Can apply Polymorphism: using object of the parent class to point to object of child classes -Can organize the program with selection control structure: if..else, switch, do..while -Can create object and can access members of data type class -Can create the data structure type of Singly Linked List, SinglyLinked List with Iterator and Java LinkedList -Can implement insert, fetch, delete, update of Linked List structures
SKILLS REQUIRED
To to this lab, students should review all the concepts required from the previous lab and add the following skills: -Learn how to create the data structure of type Linked Lists -Learn the algorithms of the operations, insert, fetch, delete, update of type Linked List structures -Learn how to show all the nodes in the Linked List structure -Learn how to declare and use Iterator to insert, fetch or delete, update in the Linked List structure
HOW TO DO EACH PART
From now and on yourLastName will be changed to your last name *Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount -Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName *Step2: -start editor eClipse, create the project → project name: FA2019_LAB5_yourLastName -add data type classes (You can use these classes from lab3) Account_yourLastName.java CheckingAccount_yourLastName.java SavingAccount_yourLastName.java -Add data structure class: SinglyLinkedList_yourLastName SinglyLinkedListIterator_yourLastName -Add the driver class FA2019_LinkedListStructureDemo_yourLastName *Step3: Write the code of classes: Re-use the code of data type classes from previous labs Write the code of SinglyLinkedList_yourLastName and SinglyLinkedListIterator: using the code on the page 189 and page 213 Based on the pseudo-code write the java code of main() of the driver class
FA2019_LinkedListStructureDemo_yourLastName *Step4: compile and run the program *Step5: debug if there is any errors to complete the program
REQUIREMENT LAB5
DATA TYPE CLASSES: Using the data type classes -class Account_yourLastName -class CheckingAccount_yourLastName -class SavingAccount_yourLastName Using the code on the page from the text book for your reference to produce the class SinglyLinkedList_yourLastName and SinglyLinkedListIterator_yourLastName. DRIVER CLASS Provide the pseudo-code or flowchart then write the code for the application FA2019_RestrictedStructureDemo_yourLastName that first display the following menu to select types of data structure: FA2019_LinkedListStructureDemo_Smith.java MAIN MENU LINKED LIST STRUCTURE – JAMES SMITH
1. Singly Linked List Structure 2. Singly Linked List Iterator Structure 3. Java Linked List With Iterator
0. Exit
TYPE1: SINGLY LINKED LIST
Create a Singly Linked List then allow users to do the following tasks:
FA2019_LinkedListStructureDemo_Smith.java MENU – SINGLY LINKED LIST – JAMES SMITH 1.Insert Account 2.Read Account 3.Verify Encapsulation 4.Update One Account 5.Delete One Account 6.Show All
Insert Account -display message to ask users to enter all the information that needs to create either a Checking account or Saving account -Insert that account to the Singly Linked List. -Check if Insert returns true, display message “The account is inserted successfully” -If insert returns false, display message: “Cannot open this account” Read Account Allow users to enter the account number to look for the Checking Account or Saving Account.
- If the Singly Linked List is empty, display the message: “There is no node in the Singly Linked List” - If the account cannot be found, display the message: “Account cannot be found” - If the it is found, display the message: “Account is found” and the information of the account VERIFY ENCAPSULATION -Ask for information of account, either it is a Checking account or Saving account and insert account to the Singly Linked List -Change the minimum amount of the account -fetch one account from Singly Linked List with the same account number of account and store it to temp -compare the minimum amount of account and temp * if both minimum amounts are the same: display the message: “Singly Lnked List is not encapsulated” * If their minimum amounts are different, display the message: “Singly Linked Lst is encapsulateded” UPDATE -Ask for information of either a Checking account or Saving account named account -insert account account to the Singly Linked List -Change the minimum amount of account -Update account to the Singly Linked List -Check if update returns true, display message “Update successfully” -if update returns false, display message “Update Not successfully” DELETE -Ask users to enter the account number of the account that they want to delete Delete the account with the account number -Check if delete returns true, display message “Account is closed” -If delete returns false, display message “Delete account failed” SHOW ALL -show all accounts in the Singly Linked list
TYPE2: SINGLY LINKED LIST WITH ITERATOR
Create a Singly Linked List with internal Iterator then do the following steps: INSERT -Allow users to insert 5 accounts (either Checking Account or Saving Account) to the Singly Linked List with Iterator SHOW ALL -show all 5 accounts in the Singly Linked List with Iterator UPDATE ALL ACCOUNTS -Each account numbers, add “19” at the beginning. For example: account number: 1234567 will become 191234567 DELETE -show all the accounts -move iterator to delete the third account in the Singly Linked List with Iterator --show all accounts to verify the account is deleted
TYPE2: JAVA LinkedList WITH ITERATOR
Create a java LinkedList with Iterator then do the following steps: INSERT -Allow users to insert 5 accounts (either Checking Account or Saving Account) to the Singly Linked List with Iterator FETCH -Fetch two first accounts in the Java LinkedList UPDATE -fetch the node at third location of iterator to variable temp -change the minimum amount temp -update at the current location with new temp -check if update returns true, display message “Account is updated” -if update returns false, display message: “Update failed” SHOW ALL -show all the LinkedList to see all accounts
HOW TO TURN IN THE LAB
Psuedo-code of main() Account_yourLastName.java CheckingAccount_yourLastName.java SavingAccount_yourLastName.java SinglyLinkedList.java SinglyLinkedListIterator.java FA2019_LinkedListStructureDemo.java Account_yourLastName.class CheckingAccount_yourLastName.class SavingAccount_yourLastName.class SinglyLinkedList.class SinglyLinkedListIterator.class FA2019_LinkedListStructureDemo.class
HOW TO GRADE THE LAB
ITEMS SCORES
Turn in on time 3
All data type classes 2
class SinglyLinkedList 1
class SinglyLinkedListIterator 1
Display menu to choose the type of list and manage the loop to terminate the program when users select Exit
2
Declare the Singly Linked list object, perform insert, fetch, verify encapsulation, delete , update and display information on each step
5
Declare the SinglyLinkedListIterator object, perform insert, Update all accounts, show all, delete
5
Declare the Java LinkedList object, Declare ListIterator object and attach it to LinkedList object, perform insert, fetch, update and show all
4
Inheritance and polymorphism 2
compile success – qualified the requirements 3
comment 2
Total scores of Lab5 30