RUVIDEO
Поделитесь видео 🙏

Solved ~ PersonSorter Person Comparator Sorting String And Integers Java (Source Code)[Netbeans] смотреть онлайн

Solved ~ PersonSorter Person Comparator Sorting String And Integers Java (Source Code)[Netbeans]
Source Code - https://sellfy.com/p/j3zcug/



PersonSorter Person Comparator Sorting String And Integers Java

Question:
Need Help!! Please follow all the comments

import java.util.Arrays;

import java.util.Comparator;

import java.util.ArrayList;

/**

Testing the Person class with two Comparators - one for sorting by name and for sorting by age

*/

public class PersonSorter



public static void main(String[] args)



Person[] persons =

new Person("Elvis", "Goodyear", 56),

new Person("Stanley", "Clark", 8),

new Person("Jane", "Graff", 16),

new Person("Nancy", "Goodyear", 69),

new Person("Alice", "Goodyear", 100)

;

System.out.println("Initial Order:");

for (int i=0; i4; i++)

Person person = persons[i];

String lastName = person.getLastName();

String firstName = person.getFirstName();

int age = person.getAge();

System.out.println(lastName + ", " + firstName + ". Age:" + age);



System.out.println();

System.out.println("Sorted by name (alphabetically):");

//-----------Start below here. To do: approximate lines of code = 6

// ToDo make a simple (inner) class that implements the Comparator interface

// to sort two person objects by name

// compare last name alphabetically. If they are equal then compare first names

// Hint: make use of the class String compareTo() method to compare name strings

















// call Array.sort with two parameters - one passing in the array of persons

// and one passing in an object of the inner class



//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

for (int i=0; i4; i++)

Person person = persons[i];

String lastName = person.getLastName();

String firstName = person.getFirstName();

int age = person.getAge();

System.out.println(lastName + ", " + firstName + ". Age:" + age);



System.out.println("Expected:\nClark, Stanley. Age:8\nGoodyear, Alice. Age:100\nGoodyear, Elvis. Age:56\nGoodyear, Nancy. Age:69");

System.out.println();

System.out.println("Sorted by age (youngest to oldest):");

//-----------Start below here. To do: approximate lines of code = 4

// ToDo make a simple (inner) class that implements the Comparator interface

// to sort two person objects by age (youngest to oldest)















// call Array.sort with two parameters - one passing in the array of persons

// and one passing in an object of the inner class



//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

for (int i=0; i4; i++)

Person person = persons[i];

String lastName = person.getLastName();

String firstName = person.getFirstName();

int age = person.getAge();

System.out.println(lastName + ", " + firstName + ". Age:" + age);



System.out.println("Expected:\nClark, Stanley. Age:8\nGraff, Jane. Age:16\nGoodyear, Elvis. Age:56\nGoodyear, Nancy. Age:69");





/**

This class Person models a person object that has a name and age.

Notice there is no constructor other than the default one.

You are setting up the ComparablePerson interface so that the

sorting will be from young to old (ascending).

*/

class Person



private String firstName;

private String lastName;

private int age;

/**

Initializes firstName, lastName and age

@param first the first name

@param last the last name

@param years the age in years

*/

public Person(String first, String last, int years)



firstName = first ; lastName = last ; age = years ;



/**

Accesses the first name

@return firstName

*/

public String getFirstName()

return firstName;



/**

Sets the first name

@param firstName the new first name

*/

public void setFirstName(String firstName)

this.firstName = firstName;



/**

Accesses the last name

@return lastName

*/

public String getLastName()

return lastName;



/**

Sets the last name

@param lastName the new value.

*/

public void setLastName(String lastName)

this.lastName = lastName;



/**

Accesses the first age

@return age

*/

public int getAge()

return age;



/**

Sets the age

@param age the n

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Solved ~ PersonSorter Person Comparator Sorting String And Integers Java (Source Code)[Netbeans]» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.