SlideShare a Scribd company logo
1 of 8
Download to read offline
Modify this code to change the underlying data structure to a double ended doubly-linked list. Data
records should be added to the end of the main array (the database) and three double ended
doubly linked lists should be maintained ; one each for the ID, LastName and FirstName. The
linked lists should (of course) be maintained in order You MUST use the driver program I have
provided , and make some additions. Remember, you should NOT be permitted to add a record
with a duplicate index number. You MUST implement all methods as I have indicated. Printing out
the data in forward order should use the "next" link in each node, printing out in reverse order
should employ the "prev" link.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class DataBase {
private DataBaseArray dbArr;
private IndexArray firstIA, lastIA, IDIA;
private DeleteStack deleteStack;
private Scanner scan;
private String nld = "n-----------------------------n";
private String dnl = "-----------------------------n";
//Default Constructor
public DataBase() {
this.dbArr = new DataBaseArray(100);
this.firstIA = new IndexArray(100, false);
this.lastIA = new IndexArray(100, false);
this.IDIA = new IndexArray(100, true);
this.deleteStack = new DeleteStack(100);
readInDataFromFile();
scan = new Scanner(System.in);
}
//Constructor for custom size
public DataBase(int maxSize) {
this.dbArr = new DataBaseArray(maxSize);
this.firstIA = new IndexArray(maxSize, false);
this.lastIA = new IndexArray(maxSize, false);
this.IDIA = new IndexArray(maxSize, true);
this.deleteStack = new DeleteStack(maxSize);
readInDataFromFile();
scan = new Scanner(System.in);
}
//Read in the initial records
public void readInDataFromFile() {
File dbData = new File("dbData.txt");
Scanner scan = new Scanner(System.in); //Have to initialize to something for compilation
try {
scan = new Scanner(dbData);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String ID = "";
String fname = "";
String lname = "";
String[] values;
while(scan.hasNextLine()) {
values = scan.nextLine().split(",");
lname = values[0];
fname = values[1];
ID = values[2];
this.insertIt(ID, fname, lname);
}
}
//Ask user to specify ID, delete that record
public void deleteIt() {
String ID = "";
System.out.println("nDELETING" + nld);
System.out.println("Please enter the ID of the record to be deleted: ");
ID = this.scan.nextLine();
if (this.IDIA.searchByKey(ID) == -1) {
System.out.println(dnl + "Record not found, please try again." + nld);
return;
}
this.delete(ID);
System.out.println(dnl + "Record successfully deleted" + nld);
}
//Ask user to specify ID, return data of that record
public void findIt() {
String ID = "";
System.out.println("nFINDING" + nld);
System.out.println("Please enter the ID of the record to be found: ");
ID = this.scan.nextLine();
int iaIndexOfRecord = this.IDIA.searchByKey(ID);
if (iaIndexOfRecord == -1) {
System.out.println(dnl + "Record not found, please try again." + nld);
return;
}
System.out.println(this.dbArr.getRecord(this.IDIA.getWhereByKey(ID)));
System.out.println(dnl + "Record found" + nld);
}
//Ask user to add a new record
public void addIt() {
String ID = "";
String first = "";
String last = "";
System.out.println("nADDING" + nld);
System.out.println("Please enter the ID of the record: ");
ID = this.scan.nextLine();
if (this.IDIA.searchByKey(ID) != -1) {
System.out.println(dnl + "ID already in use, please try again." + nld);
return;
}
System.out.println("Please enter the first name of the record: ");
first = this.scan.nextLine();
System.out.println("Please enter the last name of the record: ");
last = this.scan.nextLine();
this.insertIt(ID, first, last);
System.out.println(dnl + "Record successfully added" + nld);
}
//Insert record into database
public void insertIt(String ID, String fname, String lname) {
if (IDIA.searchByKey(ID) == -1) {
DataBaseRecord record = new DataBaseRecord(ID, fname, lname);
int where = -1;
if (this.deleteStack.isEmpty()) {
this.dbArr.addRecord(record);
} else {
where = this.deleteStack.pop();
this.dbArr.setRecord(record, where);
}
if (where < 0) {
where = this.dbArr.getSize() - 1;
}
this.firstIA.add(new IndexRecord<String>(fname, where));
this.lastIA.add(new IndexRecord<String>(lname, where));
this.IDIA.add(new IndexRecord<String>(ID, where));
}
}
//Delete a record by passing the key of the record to be deleted
public <K> void delete(K key) {
int whereToDelete = IDIA.getWhereByKey(key);
IDIA.deleteIndex(IDIA.searchByKey(key));
firstIA.deleteIndex(firstIA.searchByWhere(whereToDelete));
lastIA.deleteIndex(lastIA.searchByWhere(whereToDelete));
deleteStack.push(whereToDelete);
}
//Debugging method to print entire database
public void dumpDataBase() {
for (int i = 0; i < dbArr.getSize(); i++) {
System.out.println(dbArr.getRecord(i));
}
}
//List the database by passing the desired IndexArray and order to list in
public void list(IndexArray ia, boolean asc) {
System.out.println("nLISTING" + nld);
if (asc) {
ia.iteratorInitFront();
while(ia.hasNext()) {
System.out.println(this.dbArr.getRecord(ia.getNext()));
}
} else {
ia.iteratorInitBack();
while(ia.hasPrevious()) {
System.out.println(this.dbArr.getRecord(ia.getPrevious()));
}
}
System.out.println(dnl + "Records successfully listed" + nld);
}
//Driver methods for listing
public void ListByFirstAscending() {
this.list(firstIA, true);
}
public void ListByFirstDescending() {
this.list(firstIA, false);
}
public void ListByLastAscending() {
this.list(lastIA, true);
}
public void ListByLastDescending() {
this.list(lastIA, false);
}
public void ListByIDAscending() {
this.list(IDIA, true);
}
public void ListByIDDescending() {
this.list(IDIA, false);
}
}
public class DataBaseArray {
private DataBaseRecord[] data;
private int maxSize;
private int currSize;
//Constructor to specify size of database
public DataBaseArray(int maxSize) {
this.data = new DataBaseRecord[maxSize];
this.maxSize = maxSize;
this.currSize = 0;
}
//Inserts a record into the desired index
public void setRecord(DataBaseRecord dbr, int index) {
this.data[index] = dbr;
}
//Inserts a record at the end of the array
public void addRecord(DataBaseRecord dbr) {
if (currSize != maxSize) {
this.data[currSize] = dbr;
this.currSize++;
}
}
//Returns the current size of the array
public int getSize() {
return this.currSize;
}
//Returns the record at the specified index
public DataBaseRecord getRecord(int index) {
return data[index];
}
}
public class DataBaseRecord {
private String ID;
private String first;
private String last;
//Constructor to pass the fields to
public DataBaseRecord(String ID, String first, String last) {
this.ID = ID;
this.first = first;
this.last = last;
}
//Getter methods if needed in future
public String getID() {
return ID;
}
public String getFirst() {
return first;
}
public String getLast() {
return last;
}
//To string to print out the record
@Override
public String toString() {
return this.ID + " " + this.first + " " + this.last;
}
}
public class DeleteStack {
private int[] stack;
private int currSize;
//Constructor to pass the max size to
public DeleteStack(int maxSize) {
this.stack = new int[maxSize];
this.currSize = 0;
}
//Pushes database index onto array
public void push(int index) {
this.stack[this.currSize++] = index;
}
//Returns the database index at the end of the array and decrements the end-of-array pointer
public int pop() {
return this.stack[--this.currSize];
}
//Returns if the stack is empty
public boolean isEmpty() {
return this.currSize == 0;
}
}
public class IndexRecord<K extends Comparable<K>> {
K key;
int where;
//Constructor to pass key and where to
public IndexRecord(K key, int where) {
this.key = key;
this.where = where;
}
//Compares key of this record and another record
public int compareTo(IndexRecord otherRecord) {
return this.key.compareTo((K) otherRecord.key);
}
}
This next part is the driver
public class Driver
{
public static void main(String[] args)
{
/*The following declaration declares a data structure that will change from one assignment to the
next. For example, you will need to implement
* the following as a doubly linked list, as well as a tree.
*/
DataBase d=new DataBase();
int response;
Scanner keyboard=new Scanner(System.in);
/* Read the data into the database from the external disk file here
* IMPORTANT: duplicate ID numbers should not be added. Disregard
* the entire record for duplicate IDs
*/
do
{
System.out.println(" 1 Add a new student");
System.out.println(" 2 Delete a student");
System.out.println(" 3 Find a student by ID");
System.out.println(" 4 List students by ID increasing");
System.out.println(" 5 List students by first name increasing");
System.out.println(" 6 List students by last name increasing");
System.out.println(" 7 List students by ID decreasing");
System.out.println(" 8 List students by first name decreasing");
System.out.println(" 9 List students by last name decreasing");
System.out.println(" ");
System.out.println(" 0 End");
response=keyboard.nextInt();
switch (response)
{
case 1: d.addIt(); //Note: if the user enters an ID already in use, issue a warning and return to the
menu
break;
case 2: d.deleteIt(); //Note: output either "Deleted" or "ID not Found" and return to menu
break;
case 3: d.findIt(); //Note: output the entire record or the message "ID not Found" and return to
menu
break;
case 4: d.ListByIDAscending();
break;
case 5: d.ListByFirstAscending();
break;
case 6: d.ListByLastAscending();
break;
case 7: d.ListByIDDescending();
break;
case 8: d.ListByFirstDescending();
break;
case 9: d.ListByLastDescending();
break;
default:
}
} while (response!=0);
}
}

More Related Content

Similar to Modify this code to change the underlying data structure to .pdf

Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
 
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfUsing NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfshaktisinhgandhinaga
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdffashiionbeutycare
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfaromalcom
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfSANDEEPARIHANT
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdffantasiatheoutofthef
 
Modify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdfModify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdffcaindore
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data PipelinesHostedbyConfluent
 
PerlApp2Postgresql (2)
PerlApp2Postgresql (2)PerlApp2Postgresql (2)
PerlApp2Postgresql (2)Jerome Eteve
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIjagriti srivastava
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdffathimafancyjeweller
 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfstopgolook
 

Similar to Modify this code to change the underlying data structure to .pdf (20)

Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
3 database-jdbc(1)
3 database-jdbc(1)3 database-jdbc(1)
3 database-jdbc(1)
 
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfUsing NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorial
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
 
Write a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdfWrite a C program that reads the words the user types at the command.pdf
Write a C program that reads the words the user types at the command.pdf
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
Modify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdfModify the project so tat records are inserted into the random acess.pdf
Modify the project so tat records are inserted into the random acess.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
PerlApp2Postgresql (2)
PerlApp2Postgresql (2)PerlApp2Postgresql (2)
PerlApp2Postgresql (2)
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdf
 

More from adityaenterprise32

Most plant leaves in rainforest are thick and with waxy surf.pdf
Most plant leaves in rainforest are thick and with waxy surf.pdfMost plant leaves in rainforest are thick and with waxy surf.pdf
Most plant leaves in rainforest are thick and with waxy surf.pdfadityaenterprise32
 
Most PCcompatible computer systems use a 20bit address cod.pdf
Most PCcompatible computer systems use a 20bit address cod.pdfMost PCcompatible computer systems use a 20bit address cod.pdf
Most PCcompatible computer systems use a 20bit address cod.pdfadityaenterprise32
 
Most exoplanets found are much more massive than Earth and .pdf
Most exoplanets found are much more massive than Earth and .pdfMost exoplanets found are much more massive than Earth and .pdf
Most exoplanets found are much more massive than Earth and .pdfadityaenterprise32
 
Moodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdf
Moodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdfMoodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdf
Moodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdfadityaenterprise32
 
More effort needs to be put into the search and selection of.pdf
More effort needs to be put into the search and selection of.pdfMore effort needs to be put into the search and selection of.pdf
More effort needs to be put into the search and selection of.pdfadityaenterprise32
 
Morgan Barron is the best player on the Cornell University h.pdf
Morgan Barron is the best player on the Cornell University h.pdfMorgan Barron is the best player on the Cornell University h.pdf
Morgan Barron is the best player on the Cornell University h.pdfadityaenterprise32
 
Moosehead based in New Brunswick is the largest Canadiano.pdf
Moosehead based in New Brunswick is the largest Canadiano.pdfMoosehead based in New Brunswick is the largest Canadiano.pdf
Moosehead based in New Brunswick is the largest Canadiano.pdfadityaenterprise32
 
Month Based on this Climagraph from Columbia SC how would.pdf
Month Based on this Climagraph from Columbia SC  how would.pdfMonth Based on this Climagraph from Columbia SC  how would.pdf
Month Based on this Climagraph from Columbia SC how would.pdfadityaenterprise32
 
Monty Corp has 8000 shares of common stock outstanding It.pdf
Monty Corp has 8000 shares of common stock outstanding It.pdfMonty Corp has 8000 shares of common stock outstanding It.pdf
Monty Corp has 8000 shares of common stock outstanding It.pdfadityaenterprise32
 
Monstruos inc Mientras mira la pelcula busque elementos d.pdf
Monstruos inc  Mientras mira la pelcula busque elementos d.pdfMonstruos inc  Mientras mira la pelcula busque elementos d.pdf
Monstruos inc Mientras mira la pelcula busque elementos d.pdfadityaenterprise32
 
Mom were here Sorry were a little late Theyre more t.pdf
Mom were here Sorry were a little late Theyre more t.pdfMom were here Sorry were a little late Theyre more t.pdf
Mom were here Sorry were a little late Theyre more t.pdfadityaenterprise32
 
Money supply endogeneity and financial instability are two p.pdf
Money supply endogeneity and financial instability are two p.pdfMoney supply endogeneity and financial instability are two p.pdf
Money supply endogeneity and financial instability are two p.pdfadityaenterprise32
 
Monosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdf
Monosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdfMonosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdf
Monosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdfadityaenterprise32
 
Monopolistic competition is a market structure very much lik.pdf
Monopolistic competition is a market structure very much lik.pdfMonopolistic competition is a market structure very much lik.pdf
Monopolistic competition is a market structure very much lik.pdfadityaenterprise32
 
Moira has to be at the office from 93 but she gets to choo.pdf
Moira has to be at the office from 93 but she gets to choo.pdfMoira has to be at the office from 93 but she gets to choo.pdf
Moira has to be at the office from 93 but she gets to choo.pdfadityaenterprise32
 
Moira has to be at the office from 93 but she gets to choos.pdf
Moira has to be at the office from 93 but she gets to choos.pdfMoira has to be at the office from 93 but she gets to choos.pdf
Moira has to be at the office from 93 but she gets to choos.pdfadityaenterprise32
 
Module 1 test 101316 10 What are 3 types of nase lsted in .pdf
Module 1 test 101316 10 What are 3 types of nase lsted in .pdfModule 1 test 101316 10 What are 3 types of nase lsted in .pdf
Module 1 test 101316 10 What are 3 types of nase lsted in .pdfadityaenterprise32
 
Module 5 Case study Reas the foliewing Case study and answer.pdf
Module 5 Case study Reas the foliewing Case study and answer.pdfModule 5 Case study Reas the foliewing Case study and answer.pdf
Module 5 Case study Reas the foliewing Case study and answer.pdfadityaenterprise32
 
Modify the Simple lexer program given in the link below to .pdf
Modify the Simple lexer program given in the link below to .pdfModify the Simple lexer program given in the link below to .pdf
Modify the Simple lexer program given in the link below to .pdfadityaenterprise32
 
Modify Exercise 1adding an interface called SidedObject that.pdf
Modify Exercise 1adding an interface called SidedObject that.pdfModify Exercise 1adding an interface called SidedObject that.pdf
Modify Exercise 1adding an interface called SidedObject that.pdfadityaenterprise32
 

More from adityaenterprise32 (20)

Most plant leaves in rainforest are thick and with waxy surf.pdf
Most plant leaves in rainforest are thick and with waxy surf.pdfMost plant leaves in rainforest are thick and with waxy surf.pdf
Most plant leaves in rainforest are thick and with waxy surf.pdf
 
Most PCcompatible computer systems use a 20bit address cod.pdf
Most PCcompatible computer systems use a 20bit address cod.pdfMost PCcompatible computer systems use a 20bit address cod.pdf
Most PCcompatible computer systems use a 20bit address cod.pdf
 
Most exoplanets found are much more massive than Earth and .pdf
Most exoplanets found are much more massive than Earth and .pdfMost exoplanets found are much more massive than Earth and .pdf
Most exoplanets found are much more massive than Earth and .pdf
 
Moodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdf
Moodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdfMoodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdf
Moodys Aaa irket tahvili getirisi ile 10 yllk ABD Hazine ta.pdf
 
More effort needs to be put into the search and selection of.pdf
More effort needs to be put into the search and selection of.pdfMore effort needs to be put into the search and selection of.pdf
More effort needs to be put into the search and selection of.pdf
 
Morgan Barron is the best player on the Cornell University h.pdf
Morgan Barron is the best player on the Cornell University h.pdfMorgan Barron is the best player on the Cornell University h.pdf
Morgan Barron is the best player on the Cornell University h.pdf
 
Moosehead based in New Brunswick is the largest Canadiano.pdf
Moosehead based in New Brunswick is the largest Canadiano.pdfMoosehead based in New Brunswick is the largest Canadiano.pdf
Moosehead based in New Brunswick is the largest Canadiano.pdf
 
Month Based on this Climagraph from Columbia SC how would.pdf
Month Based on this Climagraph from Columbia SC  how would.pdfMonth Based on this Climagraph from Columbia SC  how would.pdf
Month Based on this Climagraph from Columbia SC how would.pdf
 
Monty Corp has 8000 shares of common stock outstanding It.pdf
Monty Corp has 8000 shares of common stock outstanding It.pdfMonty Corp has 8000 shares of common stock outstanding It.pdf
Monty Corp has 8000 shares of common stock outstanding It.pdf
 
Monstruos inc Mientras mira la pelcula busque elementos d.pdf
Monstruos inc  Mientras mira la pelcula busque elementos d.pdfMonstruos inc  Mientras mira la pelcula busque elementos d.pdf
Monstruos inc Mientras mira la pelcula busque elementos d.pdf
 
Mom were here Sorry were a little late Theyre more t.pdf
Mom were here Sorry were a little late Theyre more t.pdfMom were here Sorry were a little late Theyre more t.pdf
Mom were here Sorry were a little late Theyre more t.pdf
 
Money supply endogeneity and financial instability are two p.pdf
Money supply endogeneity and financial instability are two p.pdfMoney supply endogeneity and financial instability are two p.pdf
Money supply endogeneity and financial instability are two p.pdf
 
Monosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdf
Monosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdfMonosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdf
Monosodyum glutamat MSG glutamatn bir sodyum tuzu ve yayg.pdf
 
Monopolistic competition is a market structure very much lik.pdf
Monopolistic competition is a market structure very much lik.pdfMonopolistic competition is a market structure very much lik.pdf
Monopolistic competition is a market structure very much lik.pdf
 
Moira has to be at the office from 93 but she gets to choo.pdf
Moira has to be at the office from 93 but she gets to choo.pdfMoira has to be at the office from 93 but she gets to choo.pdf
Moira has to be at the office from 93 but she gets to choo.pdf
 
Moira has to be at the office from 93 but she gets to choos.pdf
Moira has to be at the office from 93 but she gets to choos.pdfMoira has to be at the office from 93 but she gets to choos.pdf
Moira has to be at the office from 93 but she gets to choos.pdf
 
Module 1 test 101316 10 What are 3 types of nase lsted in .pdf
Module 1 test 101316 10 What are 3 types of nase lsted in .pdfModule 1 test 101316 10 What are 3 types of nase lsted in .pdf
Module 1 test 101316 10 What are 3 types of nase lsted in .pdf
 
Module 5 Case study Reas the foliewing Case study and answer.pdf
Module 5 Case study Reas the foliewing Case study and answer.pdfModule 5 Case study Reas the foliewing Case study and answer.pdf
Module 5 Case study Reas the foliewing Case study and answer.pdf
 
Modify the Simple lexer program given in the link below to .pdf
Modify the Simple lexer program given in the link below to .pdfModify the Simple lexer program given in the link below to .pdf
Modify the Simple lexer program given in the link below to .pdf
 
Modify Exercise 1adding an interface called SidedObject that.pdf
Modify Exercise 1adding an interface called SidedObject that.pdfModify Exercise 1adding an interface called SidedObject that.pdf
Modify Exercise 1adding an interface called SidedObject that.pdf
 

Recently uploaded

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Modify this code to change the underlying data structure to .pdf

  • 1. Modify this code to change the underlying data structure to a double ended doubly-linked list. Data records should be added to the end of the main array (the database) and three double ended doubly linked lists should be maintained ; one each for the ID, LastName and FirstName. The linked lists should (of course) be maintained in order You MUST use the driver program I have provided , and make some additions. Remember, you should NOT be permitted to add a record with a duplicate index number. You MUST implement all methods as I have indicated. Printing out the data in forward order should use the "next" link in each node, printing out in reverse order should employ the "prev" link. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class DataBase { private DataBaseArray dbArr; private IndexArray firstIA, lastIA, IDIA; private DeleteStack deleteStack; private Scanner scan; private String nld = "n-----------------------------n"; private String dnl = "-----------------------------n"; //Default Constructor public DataBase() { this.dbArr = new DataBaseArray(100); this.firstIA = new IndexArray(100, false); this.lastIA = new IndexArray(100, false); this.IDIA = new IndexArray(100, true); this.deleteStack = new DeleteStack(100); readInDataFromFile(); scan = new Scanner(System.in); } //Constructor for custom size public DataBase(int maxSize) { this.dbArr = new DataBaseArray(maxSize); this.firstIA = new IndexArray(maxSize, false); this.lastIA = new IndexArray(maxSize, false); this.IDIA = new IndexArray(maxSize, true); this.deleteStack = new DeleteStack(maxSize); readInDataFromFile(); scan = new Scanner(System.in); } //Read in the initial records public void readInDataFromFile() { File dbData = new File("dbData.txt"); Scanner scan = new Scanner(System.in); //Have to initialize to something for compilation
  • 2. try { scan = new Scanner(dbData); } catch (FileNotFoundException e) { e.printStackTrace(); } String ID = ""; String fname = ""; String lname = ""; String[] values; while(scan.hasNextLine()) { values = scan.nextLine().split(","); lname = values[0]; fname = values[1]; ID = values[2]; this.insertIt(ID, fname, lname); } } //Ask user to specify ID, delete that record public void deleteIt() { String ID = ""; System.out.println("nDELETING" + nld); System.out.println("Please enter the ID of the record to be deleted: "); ID = this.scan.nextLine(); if (this.IDIA.searchByKey(ID) == -1) { System.out.println(dnl + "Record not found, please try again." + nld); return; } this.delete(ID); System.out.println(dnl + "Record successfully deleted" + nld); } //Ask user to specify ID, return data of that record public void findIt() { String ID = ""; System.out.println("nFINDING" + nld); System.out.println("Please enter the ID of the record to be found: "); ID = this.scan.nextLine(); int iaIndexOfRecord = this.IDIA.searchByKey(ID); if (iaIndexOfRecord == -1) { System.out.println(dnl + "Record not found, please try again." + nld); return; } System.out.println(this.dbArr.getRecord(this.IDIA.getWhereByKey(ID)));
  • 3. System.out.println(dnl + "Record found" + nld); } //Ask user to add a new record public void addIt() { String ID = ""; String first = ""; String last = ""; System.out.println("nADDING" + nld); System.out.println("Please enter the ID of the record: "); ID = this.scan.nextLine(); if (this.IDIA.searchByKey(ID) != -1) { System.out.println(dnl + "ID already in use, please try again." + nld); return; } System.out.println("Please enter the first name of the record: "); first = this.scan.nextLine(); System.out.println("Please enter the last name of the record: "); last = this.scan.nextLine(); this.insertIt(ID, first, last); System.out.println(dnl + "Record successfully added" + nld); } //Insert record into database public void insertIt(String ID, String fname, String lname) { if (IDIA.searchByKey(ID) == -1) { DataBaseRecord record = new DataBaseRecord(ID, fname, lname); int where = -1; if (this.deleteStack.isEmpty()) { this.dbArr.addRecord(record); } else { where = this.deleteStack.pop(); this.dbArr.setRecord(record, where); } if (where < 0) { where = this.dbArr.getSize() - 1; } this.firstIA.add(new IndexRecord<String>(fname, where)); this.lastIA.add(new IndexRecord<String>(lname, where)); this.IDIA.add(new IndexRecord<String>(ID, where)); } } //Delete a record by passing the key of the record to be deleted public <K> void delete(K key) {
  • 4. int whereToDelete = IDIA.getWhereByKey(key); IDIA.deleteIndex(IDIA.searchByKey(key)); firstIA.deleteIndex(firstIA.searchByWhere(whereToDelete)); lastIA.deleteIndex(lastIA.searchByWhere(whereToDelete)); deleteStack.push(whereToDelete); } //Debugging method to print entire database public void dumpDataBase() { for (int i = 0; i < dbArr.getSize(); i++) { System.out.println(dbArr.getRecord(i)); } } //List the database by passing the desired IndexArray and order to list in public void list(IndexArray ia, boolean asc) { System.out.println("nLISTING" + nld); if (asc) { ia.iteratorInitFront(); while(ia.hasNext()) { System.out.println(this.dbArr.getRecord(ia.getNext())); } } else { ia.iteratorInitBack(); while(ia.hasPrevious()) { System.out.println(this.dbArr.getRecord(ia.getPrevious())); } } System.out.println(dnl + "Records successfully listed" + nld); } //Driver methods for listing public void ListByFirstAscending() { this.list(firstIA, true); } public void ListByFirstDescending() { this.list(firstIA, false); } public void ListByLastAscending() { this.list(lastIA, true); } public void ListByLastDescending() { this.list(lastIA, false); } public void ListByIDAscending() {
  • 5. this.list(IDIA, true); } public void ListByIDDescending() { this.list(IDIA, false); } } public class DataBaseArray { private DataBaseRecord[] data; private int maxSize; private int currSize; //Constructor to specify size of database public DataBaseArray(int maxSize) { this.data = new DataBaseRecord[maxSize]; this.maxSize = maxSize; this.currSize = 0; } //Inserts a record into the desired index public void setRecord(DataBaseRecord dbr, int index) { this.data[index] = dbr; } //Inserts a record at the end of the array public void addRecord(DataBaseRecord dbr) { if (currSize != maxSize) { this.data[currSize] = dbr; this.currSize++; } } //Returns the current size of the array public int getSize() { return this.currSize; } //Returns the record at the specified index public DataBaseRecord getRecord(int index) { return data[index]; } } public class DataBaseRecord { private String ID; private String first; private String last; //Constructor to pass the fields to public DataBaseRecord(String ID, String first, String last) {
  • 6. this.ID = ID; this.first = first; this.last = last; } //Getter methods if needed in future public String getID() { return ID; } public String getFirst() { return first; } public String getLast() { return last; } //To string to print out the record @Override public String toString() { return this.ID + " " + this.first + " " + this.last; } } public class DeleteStack { private int[] stack; private int currSize; //Constructor to pass the max size to public DeleteStack(int maxSize) { this.stack = new int[maxSize]; this.currSize = 0; } //Pushes database index onto array public void push(int index) { this.stack[this.currSize++] = index; } //Returns the database index at the end of the array and decrements the end-of-array pointer public int pop() { return this.stack[--this.currSize]; } //Returns if the stack is empty public boolean isEmpty() { return this.currSize == 0; } } public class IndexRecord<K extends Comparable<K>> {
  • 7. K key; int where; //Constructor to pass key and where to public IndexRecord(K key, int where) { this.key = key; this.where = where; } //Compares key of this record and another record public int compareTo(IndexRecord otherRecord) { return this.key.compareTo((K) otherRecord.key); } } This next part is the driver public class Driver { public static void main(String[] args) { /*The following declaration declares a data structure that will change from one assignment to the next. For example, you will need to implement * the following as a doubly linked list, as well as a tree. */ DataBase d=new DataBase(); int response; Scanner keyboard=new Scanner(System.in); /* Read the data into the database from the external disk file here * IMPORTANT: duplicate ID numbers should not be added. Disregard * the entire record for duplicate IDs */ do { System.out.println(" 1 Add a new student"); System.out.println(" 2 Delete a student"); System.out.println(" 3 Find a student by ID"); System.out.println(" 4 List students by ID increasing"); System.out.println(" 5 List students by first name increasing"); System.out.println(" 6 List students by last name increasing"); System.out.println(" 7 List students by ID decreasing"); System.out.println(" 8 List students by first name decreasing"); System.out.println(" 9 List students by last name decreasing"); System.out.println(" "); System.out.println(" 0 End"); response=keyboard.nextInt();
  • 8. switch (response) { case 1: d.addIt(); //Note: if the user enters an ID already in use, issue a warning and return to the menu break; case 2: d.deleteIt(); //Note: output either "Deleted" or "ID not Found" and return to menu break; case 3: d.findIt(); //Note: output the entire record or the message "ID not Found" and return to menu break; case 4: d.ListByIDAscending(); break; case 5: d.ListByFirstAscending(); break; case 6: d.ListByLastAscending(); break; case 7: d.ListByIDDescending(); break; case 8: d.ListByFirstDescending(); break; case 9: d.ListByLastDescending(); break; default: } } while (response!=0); } }