feat(java): Creador de diccionarios del lenguaje inventado hecho.

main
KyMAN 3 months ago
parent dbc09ebfb6
commit da7199c549
  1. 8
      .gitignore
  2. 4
      Actividad2/lenguaje/build/built-jar.properties
  3. BIN
      Actividad2/lenguaje/build/classes/lenguaje/Lenguaje.class
  4. 32
      Actividad2/lenguaje/dist/README.TXT
  5. BIN
      Actividad2/lenguaje/dist/lenguaje.jar
  6. 39
      Actividad2/lenguaje/src/lenguaje/Lenguaje.java
  7. 3
      lenguaje.sh

8
.gitignore vendored

@ -1,7 +1 @@
# /ordenarNumeros/nbproject/private/
# /ordenarNumeros/build/
# /aleatorios/nbproject/private/
# /aleatorios/build/
# /aleatorios/dist/
# /ordenarNumeros/dist/
# /lenguaje/nbproject/private/
diccionario.txt

@ -0,0 +1,4 @@
#Mon, 26 Feb 2024 18:04:18 +0100
/home/DAM2024/PSP01_Tarea/Actividad2/lenguaje=

@ -0,0 +1,32 @@
========================
BUILD OUTPUT DESCRIPTION
========================
When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).
To run the project from the command line, go to the dist folder and
type the following:
java -jar "lenguaje.jar"
To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.
Notes:
* If two JAR files on the project classpath have the same name, only the first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, these files (folders)
are not copied.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.

Binary file not shown.

@ -4,6 +4,13 @@
*/
package lenguaje;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
/**
*
* @author kyman
@ -15,6 +22,38 @@ public class Lenguaje {
*/
public static void main(String[] args) {
// TODO code application logic here
int numero_de_palabras = Integer.parseInt(args[0]);
String path = args[1];
String alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int l = alfabeto.length();
try (BufferedWriter archivo = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path)))) {
for(int i = 0; i < numero_de_palabras; i ++){
String palabra = "";
while(palabra.length() < 3 || Math.random() < .8)
palabra += alfabeto.charAt((int)(Math.random() * l));
try {
archivo.append(palabra + "\n");
}catch(IOException excepcion){
Lenguaje.excepcion(excepcion);
}
}
}catch(FileNotFoundException excepcion){
Lenguaje.excepcion(excepcion);
}catch(IOException excepcion){
Lenguaje.excepcion(excepcion);
}
}
private static void excepcion(Exception exception){
System.out.println(exception.getMessage());
System.out.println(Arrays.toString(exception.getStackTrace()));
}
}

@ -0,0 +1,3 @@
#!/bin/bash
directorio=`dirname $(readlink -f "$0")`
java -jar $directorio/Actividad2/lenguaje/dist/lenguaje.jar 40 diccionario.txt
Loading…
Cancel
Save