Commit b8cfca3d by Pedro J Sanchez

v0.1 Estructura inicial proyecto de prueba para el curso Java EE

parents
# Created by https://www.gitignore.io/api/code-java,java,java-web
# Edit at https://www.gitignore.io/?templates=code-java,java,java-web
### Code-Java ###
# Language Support for Java(TM) by Red Hat extension for Visual Studio Code - https://marketplace.visualstudio.com/items?itemName=redhat.java
.project
.classpath
factoryConfiguration.json
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Java-Web ###
## ignoring target file
target/
# End of https://www.gitignore.io/api/code-java,java,java-web
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>es.uja.cursoJEE</groupId>
<artifactId>SimulaEventos</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<name>SimulaEventos</name>
</project>
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.uja.cursojee.simulaeventos;
import java.util.Random;
/**
* Interface con las constantes necesarias para la resolución del ejercico
* @author pedroj
*/
public interface Constantes {
// Generador aleatorio
public static final Random aleatorio = new Random();
// Tipos de eventos para las pruebas
public enum TipoEvento {
CHARLA(15,6), CURSO(40,2), DEPORTES(70,4), CULTURA(100,3);
private final int prob;
private final int duracion;
private TipoEvento(int prob, int duracion) {
this.prob = prob;
this.duracion = duracion;
}
/**
* Nos devuelve un tipo de evento aleatorio atendiendo a su probabilidad
* @return el tipo de evento generado
*/
public static TipoEvento getEvento() {
int prob = aleatorio.nextInt(D100);
TipoEvento resultado = null;
int i = 0;
while( (i < EVENTOS.length) && (resultado == null) ) {
if ( EVENTOS[i].prob > prob )
resultado = EVENTOS[i];
i++;
}
return resultado;
}
public int duracionEvento() {
return aleatorio.nextInt(VARIACION) + duracion;
}
}
public static final TipoEvento[] EVENTOS = TipoEvento.values();
// Constantes del problema
public static final int D100 = 100; // Simula una tirada de dado
public static final int VARIACION = 3;
public static final int TIEMPO_SIMULADO = 4; // segundos
public static final int TIEMPO_ESPERA = 30; // segundos
public static final int NUM_EVENTOS = 20;
public static final int NUM_USUARIOS = 1000;
public static final int NUM_AGENTES = 5;
public static final int NUM_GESTORES = 5;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.uja.cursojee.simulaeventos;
import es.uja.cursojee.simulaeventos.Constantes.TipoEvento;
import java.util.Date;
/**
*
* @author pedroj
*/
public class Evento {
private final String idEvento;
private final TipoEvento tipo;
private final String lugar;
private final Date fecha;
private final String descripcion;
private final int aforo;
public Evento(String idEvento, TipoEvento tipo, String lugar, Date fecha,
String descripcion, int aforo) {
this.idEvento = idEvento;
this.tipo = tipo;
this.lugar = lugar;
this.fecha = fecha;
this.descripcion = descripcion;
this.aforo = aforo;
}
public String getIdEvento() {
return idEvento;
}
public TipoEvento getTipo() {
return tipo;
}
public String getLugar() {
return lugar;
}
public Date getFecha() {
return fecha;
}
public String getDescripcion() {
return descripcion;
}
public int getAforo() {
return aforo;
}
@Override
public String toString() {
return "Evento\n" + "\tidEvento=" + idEvento + "\n\ttipo=" + tipo +
"\n\tlugar=" + lugar + "\n\tfecha=" + fecha +
"\n\tdescripcion=" + descripcion + "\n\taforo=" + aforo + '}';
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.uja.cursojee.simulaeventos;
/**
*
* @author pedroj
*/
public class SimulaEventos {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Variables aplicación
// Ejecución del hilo principal
System.out.println("Hilo(PRINCIPAL) comienza la ejecución");
// Inicialización de las variables para la prueba
// Se ejecutan los hilos secundario
// Espera a la finalización de los hilos secundarios
// Finalización del hilo principal
System.out.println("Hilo(PRINCIPAL) ha fializado la ejecución");
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.uja.cursojee.simulaeventos;
/**
*
* @author pedroj
*/
public class TareaAgente implements Runnable {
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.uja.cursojee.simulaeventos;
/**
*
* @author pedroj
*/
public class TareaGestor implements Runnable {
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package es.uja.cursojee.simulaeventos;
/**
*
* @author pedroj
*/
public class Usuario {
private final String nombre;
private final String login;
private String password;
public Usuario(String nombre, String login) {
this.nombre = nombre;
this.login = login;
this.password = null;
}
public String getNombre() {
return nombre;
}
public String getLogin() {
return login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "Usuario{" + "nombre=" + nombre + ", login=" + login + '}';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment