// // Created by Julio Tentor // public class CasoEjemplo_b { public void Run() { ILinkedList orignalList = getData(); System.out.println("Lista original.:" + orignalList.toString()); ILinkedList uppercaseList = new SimpleLinkedList(); for (Character ch; orignalList.size() > 0; ) { ch = orignalList.removeFirst(); if (Character.isLowerCase(ch)) { uppercaseList.addLast(Character.toUpperCase(ch)); } else { uppercaseList.addLast(ch); } } System.out.println("Lista procesada:" + uppercaseList.toString()); } private ILinkedList getData() { Integer option; while (true) { System.out.println( "\nTrabajo Práctico Nº 4 - Caso Ejempo b)\n" + "\nOpciones" + "\n 1. Ingresa valores por consola" + "\n 2. Genera valores aleatorios" ); option = Helper.getInteger("\nSu opción: "); switch (option) { case 1: return consoleInput(); case 2: return randomGenerate(); } } } private ILinkedList consoleInput() { ILinkedList list = new SimpleLinkedList(); Character ch; while (true) { ch = Helper.getCharacter("Ingrese una letra (@ para finalizar): "); if (ch.equals('@')) { break; } list.addLast(ch); } return list; } private ILinkedList randomGenerate() { ILinkedList list = new SimpleLinkedList(); String characters = "ABCDEFGHIJKLMNÑOPRSTUVWXYZabcdefghijklmnñoprstuvwxyz"; for (int count = Helper.random.nextInt(20) + 1; count > 0; --count) { list.addLast(characters.charAt(Helper.random.nextInt(characters.length()))); } return list; } }