Hello, I was wondering how I would go about creating a 2 class project based upo
ID: 3649335 • Letter: H
Question
Hello, I was wondering how I would go about creating a 2 class project based upon the constraints below:REQURIEMENT:
Provide the application named as SortingApplication that does the following:
prompts users to select one type of sorting algorithm from the menu
allow users enter a list of integer numbers and the program read the list as a string
display the sorted result as follows format (for example if Bubble sort is selected)
Sorting method: BUBBLE SORT
Original list of numbers: 34 2 15 33 17 8
Sorted list: 2 8 15 17 33 34
The application should allow users to continue choosing a sorting method and terminates when users choose to exit
All the sorting algorithms should be hidden from the client side and the number of integers input to sort is not limited.
Hint: You should define a class named IntegerArray that maintains an integer array and a sorting method
The constructor should accept the list of numbers entered from keyboard as a String and the sorting method.
Based on the sorting method chosen from users, a method of sorting algorithm will be called, and the result will be displayed.
The sort methods could insertionSort, bubbleSort, selectionSort and their algorithms are provided below
The following are some sorting algorithm provide for your reference. You should not just copy these algorithms to your class; learn the logic and find the way to place them to your class.
public void insertionSort( )
{
for (int i = 1; i < n; i++)
{
int j = i;
int B = array[i];
while ((j > 0) && (array[j-1] > B))
{
array[j] = array[j-1];
j--;
}
array[j] = B;
}
} //where array is an array with size = n
public void bubbleSort( ) {
int n = x.length;
for (int pass=1; pass < n; pass++) { // count how many times
// This next loop becomes shorter and shorter
for (int i=0; i < n-pass; i++) {
if (x[i] > x[i+1]) {
// exchange elements
int temp = x[i];
x[i] = x[i+1];
x[i+1] = temp;
}
}
}
} //where x is an array with size = n
public void selectionSort( ) {
for (int i=0; i<x.length-1; i++) {
for (int j=i+1; j<x.length; j++) {
if (x[i] > x[j]) {
//... Exchange elements
int temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}
} //where x is an array with size = n
Explanation / Answer
Both are based on a set of principles, including design by contract, ... Under Eiffel's design, a software text should be able to reproduce its design .... Finally, scoping can be selectively and precisely controlled to any class in the Eiffel project universe, ... class HELLO_WORLD create make feature make do print ("Hello, world!
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.