Encerrado

java program

For this program use the Person class and the SearchSortAlgorithms<T> class(both included in additional info) the main program will create an array of Person objects capable of holding the names of 5 presidents. You should instantiate the Person objects and initialize them with the names listed below in the order that they served the US:

George Washington

Theodore Roosevelt

Woodrow Wilson

Franklin Roosevelt

George Bush

After initializing the Person objects, use a loop to print the names in the order that they are stored in the array. Then, use an object of the SearchSortAlgorithm<Person> to selection sort the array. Again, use a loop to print the names after they have been sorted.

For the Person class, you will need to add code to implement the Comparable interface. The compareTo method should compare the names using a last name first and then first name comparison scheme.

## Deliverables

Person class

public class Person{

private String firstName;

private String lastName;

public Person(){

firstName = "";

lastName = "";

}

public Person(String first, String last){

setName(first, last);

}

public String toString(){

return (firstName + " " + lastName);

}

public void setName(String first, String last){

firstName = first;

lastName = last;

}

public void setFirstName(String first){

firstName = first;

}

public void setLastName(String last){

lastName = last;

}

public String getFirstName(){

return firstName;

}

public String getLastName(){

return lastName;

}

}

SearchSortAlgorithms<T> class

public class SearchSortAlorithms<T>{

public void selectionSort(T[] list, int listLength){

int smallestIndex;

T temp;

for (int index = 0; index < listLength - 1; index++){

smallestIndex = index;

for(int minIndex = index + 1; minIndex < listLength; minIndex++){

Comparable<T> compElem = (Comparable<T>) list[minIndex];

if ([url removed, login to view](list[smallestIndex]) < 0)

smallestIndex = minIndex;

}

temp = list[smallestIndex];

list[smallestIndex] = list[index];

list[index] = temp;

}

}

}

Habilidades: Engenharia, Java, Microsoft, Gestão de projetos, Arquitetura de software, Teste de Software, Área de trabalho do Windows

Ver mais: sort array list in java, sort array c, java 1.5 for loop, franklin in, first franklin, first class objects in java, windows 7 program, presidents, franklin, Bush, java selection sort, order java, create java object, java program interface, selection sort program, interface java program, Java string, implement java, program sort, string compare, object program, list java array, index java code, implement holding, java method

Acerca do Empregador:
( 6 comentários ) United States

ID do Projeto: #2985384

11 freelancers estão ofertando em média $4 para este trabalho

vishaygupta

See private message.

$4.25 USD em 1 dia
(62 Comentários)
6.1
LoboSoft

See private message.

$4.25 USD em 1 dia
(16 Comentários)
4.6
ivankorhner

See private message.

$4.25 USD em 1 dia
(45 Comentários)
4.7
frlncdvlpr

See private message.

$3.4 USD em 1 dia
(31 Comentários)
4.2
softwareDevloper

See private message.

$4.25 USD em 1 dia
(9 Comentários)
3.4
serjrac

See private message.

$4.25 USD em 1 dia
(10 Comentários)
2.7
bubra

See private message.

$3.4 USD em 1 dia
(7 Comentários)
2.0
gordonc45

See private message.

$4.25 USD em 1 dia
(3 Comentários)
1.6
inxscoder

See private message.

$4.25 USD em 1 dia
(0 Comentários)
0.0
path2727

See private message.

$4.25 USD em 1 dia
(0 Comentários)
0.0
jansonw

See private message.

$4.25 USD em 1 dia
(0 Comentários)
0.0