Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Punto05 {
- public static void main(String[] args) {
- Queue<Correo> bandejaEntrada = new Queue<>();
- Queue<Correo> bandejaPrincipal = new Queue<>();
- Queue<Correo> bandejaSocial = new Queue<>();
- Queue<Correo> bandejaPromociones = new Queue<>();
- Scanner entrada = new Scanner(System.in);
- int cont =0;
- while (cont!=4){
- switch(cont){
- case 1:
- recibirCorreo(entrada,bandejaEntrada);
- separarCorreos(bandejaEntrada,bandejaPrincipal,bandejaSocial,bandejaPromociones);
- break;
- case 2:
- correoRandom(bandejaEntrada,entrada);
- separarCorreos(bandejaEntrada,bandejaPrincipal,bandejaSocial,bandejaPromociones);
- break;
- case 3:
- mostrarBandejas(bandejaPrincipal,bandejaSocial,bandejaPromociones);
- break;
- }
- cont=Helper.elegirOpcion(entrada, "'Bandeja de correos' \n1-Manual \n2-Random \n3-Ver bandejas de correo \n4-Salir");
- }
- }
- public static void recibirCorreo(Scanner entrada, Queue<Correo> bandeja) {
- Correo correo;
- String remitente,asunto,cuerpo;
- int continuar;
- do{
- remitente = Helper.cargarLetra(entrada, "Ingrese remitente: ");
- asunto = Helper.cargarLetra(entrada, "Ingrese asunto: ");
- cuerpo = Helper.cargarLetra(entrada, "Ingrese cuerpo: ");
- correo = new Correo(remitente, asunto, cuerpo);
- bandeja.offer(correo);
- continuar = Helper.elegirOpcion(entrada,"'opcion' \n1-Seguir Cargando \n2-Salir");
- } while(continuar!=2);
- }
- private static void correoRandom(Queue<Correo> bandejaEntrada,Scanner entrada) {
- Correo correo;
- String remitente,asunto,cuerpo;
- int continuar;
- do{
- remitente = nombreRandom("Generando remitente aleatorio...");
- asunto = asuntoRandom("Generando asunto aleatorio...");
- System.out.println("Generando un cuerpo de correo...");
- cuerpo = ("Recibiste una notificacion de "+asunto +" enviada por "+remitente);
- correo = new Correo(remitente, asunto, cuerpo);
- bandejaEntrada.offer(correo);
- continuar = Helper.elegirOpcion(entrada,"'opcion' \n1-Seguir Cargando \n2-Salir");
- } while(continuar!=2);
- }
- public static String nombreRandom(String mensaje){
- int random;
- System.out.println(mensaje);
- String [] nombre ={"Domingo Galan","Ricardo Ribas ","Erik Diego","Abel Valdivia","Laila PiƱeiro","Delfina Torralba","Florencia Alvaro","Ariadna Espin","Angelina Manso","Martina Ros"};
- random = (int) (Math.random() * nombre.length);
- return nombre[random];
- }
- public static String asuntoRandom(String mensaje){
- int random;
- System.out.println(mensaje);
- String [] nombre ={"Facebook","Twitter","Youtube","Instagram","Promocion","Oferta","Viajes","Venta","Urgencia","Saludo familiar","Reunion"};
- random = (int) (Math.random() * nombre.length);
- return nombre[random];
- }
- public static void separarCorreos(Queue<Correo> bandeja, Queue<Correo> bandejaPrincipal, Queue<Correo> bandejaSocial, Queue<Correo> bandejaPromociones) {
- Correo identificar;
- String remitente,asunto,cuerpo;
- int continuar;
- while(!bandeja.estaVacia()){
- identificar =(Correo) bandeja.pool();
- if (identificar.getAsunto().equalsIgnoreCase("Facebook") || identificar.getAsunto().equalsIgnoreCase("Youtube") || identificar.getAsunto().equalsIgnoreCase("Instagram")|| identificar.getAsunto().equalsIgnoreCase("Twitter")){
- bandejaSocial.offer(identificar);
- continue;
- }
- if (identificar.getAsunto().equalsIgnoreCase("Oferta") || identificar.getAsunto().equalsIgnoreCase("Venta") || identificar.getAsunto().equalsIgnoreCase("Viajes")|| identificar.getAsunto().equalsIgnoreCase("Promocion")){
- bandejaPromociones.offer(identificar);
- continue;
- }
- else {
- bandejaPrincipal.offer(identificar);
- }
- }
- }
- public static void mostrarBandejas(Queue<Correo> bandejaPrincipal, Queue<Correo> bandejaSocial, Queue<Correo> bandejaPromociones) {
- System.out.println("Bandeja de entrada vacia...");
- System.out.println("Bandeja Principal: "+bandejaPrincipal.toString());
- System.out.println("Bandeja Social: "+bandejaSocial.toString());
- System.out.println("Bandeja de Promociones: "+bandejaPromociones.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment