Starting from:
$30

$24

Homework 10 SOlution

The goal of this homework is to practice adapter pattern. In Homework 8, you implemented the binary search algorithm, which works with an interface called SearchableVector. In Homework 9, you implemented a class called IntegerVectorSortable. In this homework, you need to implement a called called IntegerVectorSortableSearchable that uses the functions in the IntegerVectorSortable to implement the interface defined in SearchableVector. Thus, an IntegerVectorSortableSearchable object will be able to collaborate with both your bubble sorting algorithm (in the increasing order) and your binary search algorithm. Your program must use the following main function:










int main(int argc, char** argv) {




IntegerVectorSortableSearchable ivss;




ivss.setQuery(0);




ivss.insertInteger(9);




ivss.insertInteger(3);




ivss.insertInteger(7);




ivss.insertInteger(5);




ivss.insertInteger(8);




ivss.insertInteger(1);




ivss.insertInteger(4);




ivss.insertInteger(2);




ivss.insertInteger(3);




BubbleSortIncreasing bsi;




bsi.sort(&ivss);


























































}




BinarySearch bs;




cout<<"All integers are: "<<endl;




ivss.print();




int query = 1;




while(query!=0){




cout<<"Please input the number that you want to search: "; cinquery;




ivss.setQuery(query);




int searchResult=bs.search(&ivss);




cout<<endl;




if(searchResult==-1) cout<<"There is no match!"<<endl;




} else cout<<"Find match at the "<<searchResult<<"th element!"<<endl; return 0;






Initially, your program prints the following:












After you type in a number, say 1, press return twice, it will print the following and wait for you to type in another number to search.



















Finally, if you input 0, then it will print “There is no match!” and terminates.










Due: February 17, 11:59PM, 2019.










Turn in one file via handin: the zip file of (1) your whole NetBean directory and (2) your UML digram file named uml.pdf. The name of your zip file should be: LastName_FirstName.zip. For example, if your name is John Smith, you should turn in one files: Smith_John.zip.

More products