Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TP4;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Ejercicio_5 {
- private ILinkedList<Schedule> Agends;
- public void Run() {
- Agends = new SimpleLinkedList<>();
- getData();
- System.out.println("Los datos son: " + Agends.toString());
- }
- private void getData() {
- Integer Option;
- while(true) {
- System.out.println(
- "\n Trabajo Practico N°4 - Ejercicio 4 \n" +
- "\nOpciones" +
- "\n 1. Ingresa valores por consola" +
- "\n 2. Generar valores aleatorios"
- );
- Option = Helper.getInteger();
- switch (Option) {
- case 1:
- //consoleInput();
- return;
- case 2:
- //consoleGenerate();
- return;
- }
- }
- }
- private void consoleInput() {
- String Full_Name = "";
- String Work;
- Integer Telephone;
- String Mail;
- int position;
- char resp;
- System.out.println("\n Ingrese los datos a agendar");
- do {
- do {
- System.out.println("Ingrese Nombre Completo: ");
- Full_Name = Helper.getString();
- } while (Validate_FullName(Full_Name));
- System.out.println("Ingrese Trabajo o Empresa: ");
- Work = Helper.getString();
- do {
- System.out.println("Ingrese numero de celular: ");
- Telephone = Helper.getIntegerPositive();
- } while (ValidateCel(Integer.toString(Telephone)));
- do {
- System.out.println("Ingrese correo: ");
- Mail = Helper.getString();
- } while (ValidateMail(Mail));
- while (true) {
- System.out.println("Donde agrega el producto [1. Adelante, 2. Final]");
- position = Helper.getInteger();
- if (position == 1) {
- Agends.addFirst(new Schedule(Full_Name, Work, Telephone, Mail));
- break;
- } else {
- if (position == 2) {
- Agends.addLast(new Schedule(Full_Name, Work, Telephone, Mail));
- break;
- }
- }
- }
- do {
- System.out.println("Desea cargar mas Datos (S/N)");
- resp = Helper.getChar();
- } while (validateChar(resp));
- } while (resp == 'S');
- }
- private void radomGenerate() {
- String Full_Name = "";
- String Work;
- Integer Telephone;
- String Mail;
- int position;
- for (int count=Helper.random.nextInt(20)+1 ; count > 0 ; -- count) {
- Full_Name= FullName[Helper.random.nextInt(FullName.length)];
- Work= work[Helper.random.nextInt(work.length)];
- Telephone= Cel[Helper.random.nextInt(Cel.length)];
- Mail= mail[Helper.random.nextInt(mail.length)];
- position= Helper.random.nextInt(2) + 1;
- if(position == 1) {
- Agends.addFirst(new Schedule(Full_Name, Work, Telephone, Mail));
- } else {
- if(position == 2) {
- Agends.addLast(new Schedule(Full_Name, Work, Telephone, Mail));
- }
- }
- }
- }
- private boolean Validate_FullName(String Full_Name) {
- Pattern pattern = Pattern.compile("[^([A-Z]{1}[a-z]+[ ]){1,3}$");
- Matcher mather = pattern.matcher(Full_Name);
- if(mather.find()) {
- return false;
- } else {
- System.out.println("Error...");
- System.out.println("El nombre ingresado es incorrecto");
- return true;
- }
- }
- public boolean ValidateCel(String Telephone){
- Pattern pattern = Pattern.compile("^(15)[0-9]{10}$");
- Matcher mather = pattern.matcher(Telephone);
- if (mather.find()) {
- return false;
- } else {
- System.out.println("Error...");
- System.out.println("El Num. de Celular debe estar comprendido entre 12 cifras");
- System.out.println("EJ: 15 4040314");
- return true;
- }
- }
- public boolean ValidateMail(String Mail){
- Pattern pattern = Pattern.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
- Matcher mather = pattern.matcher(Mail);
- if (mather.find()) {
- return false;
- } else {
- System.out.println("Error...");
- System.out.println("El mail ingresado es incorrecto");
- return true;
- }
- }
- public boolean validateChar(char resp){
- switch (resp){
- case 's': return false;
- case 'S': return false;
- case 'n': return false;
- case 'N': return false;
- default:{
- System.out.println("Debe ingresar (S/N)");
- return true;
- }
- }
- }
- static String [] FullName = new String [] {
- "Ana Mamani",
- "Luciana Lopez",
- "Mariana Flores",
- "Gustavo Quispe",
- "Luciano Herrera",
- "Enzo Lopez",
- "Mariano Gaspar",
- "Hugo Albornoz",
- "Celeste Aban",
- "Emilio Gareca"
- };
- static String [] work = new String [] {
- "Contador",
- "Arquitecto",
- "Abogado",
- "Ingeniero",
- "Medico",
- "Enfermero",
- };
- static String [] mail = new String [] {
- "nojofapouho-2479@hotmail.com",
- "kibredayeppe-2034@gmail.com",
- "loucraseuppaddo-5744@hotmail.com",
- "colorekeissu-4864@gmail.com",
- "jillunegroipra-9474@gmail.com",
- "duprizeiquajo-2695@hotmail.com",
- "tureipeddoili-1853@hotmail.com",
- "wobaxehipei-3003@hotmail.com",
- "woyetrepreule-2878@gmail.com",
- "pekegeyenne-3980@hotmail.com",
- };
- static int [] Cel = new int [] {
- 154464257,
- 155665587,
- 154885698,
- 154668844,
- 154040314,
- 154448853,
- 155666313,
- 154854975,
- 154444684,
- 154552689,
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement