Aide en java

Fermé
Momo - 8 déc. 2015 à 16:30
NHenry Messages postés 15173 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 21 décembre 2024 - 8 déc. 2015 à 18:20
Bonjour,

Est ce que quelqu'un peut m'aider à résoudre cet exercice:

Exercise 1 – Callbacks
Use the given CountryLoader.getCountries method to load the file WorldCountries.txt
containing information about world countries (their names, populations and areas) into an
ArrayList<Country>. Then make some processing of that information as explained below, by using
the callback technique.

First, select the data you want to process: either the populations or the areas. Use for this the interface:
public interface ValueSelector {
public int getValue(Country country);
}
whose implementations (PopulationSelector or AreaSelector) return the data values you
want to process. Also provide a filter to limit the number of values processed (e.g. process only countries
with at least 1 million inhabitants or only countries with at least 100000 km 2 ). This filter should
implement the interface:
public interface Filter {
public boolean accept(Object obj);
}
and be activated each time a data is selected.

Then, select the operation you want to execute on the selected data: either computing the sum or the
average of the data values. Use for this the interface:
public interface Operator {
public long calculate(java.util.List<Country> countries,
ValueSelector selector);
}
whose implementations (Adder or AvgOperator) carry out the operation you want to process and
return the result.

Now, process the country information according to your selections (e.g. calculate the sum of the world
population or the average of all country areas that have at least 100000 km 2 ) and display the
corresponding result. Also print a list of the processed countries, sorted according to the selected data
values (use the Collections.sort method with an appropriate comparator) with their names,
populations, areas and population densities.
To control your program, i.e. to make your selections and activate the processing, build a little GUI with 5
buttons:
o Population and Area, to select the data to process. (To enter a filter value, call a
TextInputDialog).
o Add and Average, to select the operation to execute
o Execute, to activate the processing
A voir également:

1 réponse

NHenry Messages postés 15173 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 21 décembre 2024 350
8 déc. 2015 à 18:20
Selon le théorème de CCM, toute demande d'aide au devoir finit implacablement plongée dans les profondeurs des messages hors sujets.
Sur ce, je vous invite à prendre connaissance de cette information concernant vos demandes de devoirs.
0