Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package coreservlets.jsf.ss06;
- import java.util.ArrayList;
- import java.util.List;
- import javax.faces.model.SelectItem;
- public class LanguageUtils
- {
- private static String[] languages = { "Java", "JavaScript", "C#", "C++", "PHP", "Python", "Perl", "Ruby", "Scala" };
- private static List<SelectItem> availableLanguages;
- static
- {
- availableLanguages = new ArrayList<SelectItem>();
- for( String language: languages )
- {
- availableLanguages.add( new SelectItem( language ) );
- }
- }
- public static List< SelectItem > languagesList()
- {
- return( availableLanguages );
- }
- public static List<String> randomLanguages( int numLanguagesToStudy )
- {
- List< String > randomLanguages = new ArrayList<String>();
- for (int i = 0; i < numLanguagesToStudy; i++ )
- {
- randomLanguages.add( languages[ new java.util.Random().nextInt(9 ) ] );
- }
- return randomLanguages;
- }
- public static String findMostPopularLanguage( int index )
- {
- return( languages[ index ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement