Estructura de datos
Carlos HinostrozaInforme5 de Mayo de 2022
26.306 Palabras (106 Páginas)71 Visitas
[pic 1] [pic 2]
TALLER 0
Integrantes:
Slavko Bogdanic
Cristian Castro
Inti Cerda
Tabla de contenido
TALLER 0 1
Estructura de datos 2
Vectores de uso general: 2
2
Base de datos usuarios: 2
2
Base de datos de Hechizos: 3
3
Base de datos de Enemigos: 3
3
Estructura del programa 5
Código del programa: 6
Estructura de datos
Vectores de uso general:
[pic 3]
Base de datos usuarios:
[pic 4]
Base de datos de Hechizos:
[pic 5]
Base de datos de Enemigos:
[pic 6]
Matriz Hechizos:
[pic 7]
Estructura del programa
[pic 8]
Código del programa:
package taller0;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import java.lang.Math;
import java.io.FileWriter;
import java.io.BufferedWriter;
public class Main {
//Este subprograma lee los hechizos y los guarda en 2 vectores interrelacionados, donde uno tiene el nombre y el otro el ataque.
//Tambi�n coloca el n�mero de hechizos en un vector aparte.
public static void leerHechizos(String[] hechizos, int[] atkHechizos, int[]dataJuego)throws IOException {
int contador = 0;
File archivo3 = new File("Hechizos.txt");
Scanner lectura4 = new Scanner(archivo3);
while(lectura4.hasNextLine()) {
String[] partes = lectura4.nextLine().split(",");
hechizos[contador] = partes[0];
atkHechizos[contador] = Integer.parseInt(partes[1]);
contador++;
}
lectura4.close();
dataJuego[1] = contador;
}
//Ac�, los datos de los archivos "Jugadores.txt" y "HechizosJugadores.txt" son cargados a los vectores del programa.
//Tener en cuenta que la matriz guarda sus datos as�: matrizHechizosJugadores[FilaHechizos][NumeralJugador]
public static void leerJugadores(String[] vecUser, String[] vecPass,int[] vecHP, int[] vecATK, int[] vecDEF,int[] vecAGI,
int[] vecNHZ, int[] vecEXP,String[][] matrizHechizosJugadores, int[] dataJuego) throws IOException{
int contador = 0;
File archivo3 = new File("Jugadores.txt");
File archivo2 = new File("HechizosJugadores.txt");
Scanner read3 = new Scanner(archivo3);
Scanner read2 = new Scanner(archivo2);
while(read3.hasNextLine()){
String[] partes = read3.nextLine().split(",");
String usuario = partes[0];
String contraseña = partes[1];
int hp = Integer.parseInt(partes[2]);
int atk = Integer.parseInt(partes[3]);
int def = Integer.parseInt(partes[4]);
int agi = Integer.parseInt(partes[5]);
int nhz = Integer.parseInt(partes[6]);
int exp = Integer.parseInt(partes[7]);
...