-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor y optimize de todo el proyecto
- Loading branch information
1 parent
93d1f5d
commit d10d529
Showing
6 changed files
with
111 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,68 @@ | ||
|
||
import java.sql.Time; | ||
import java.util.NoSuchElementException; | ||
import java.util.Scanner; | ||
import java.util.Timer; | ||
|
||
public class AplicacionIMDB { | ||
|
||
public static CatalogoIMDB catalogo; | ||
public static void main(String[] args){ | ||
catalogo = CatalogoIMDB.getInstance(); | ||
//TO DO: ... | ||
|
||
//TO DO: Cargar películas | ||
catalogo.cargarPeliculas("films.txt"); | ||
|
||
//TO DO Cargar intérpretes | ||
catalogo.cargarInterpretes("cast.txt"); | ||
|
||
//Menú | ||
|
||
Scanner sc = new Scanner(System.in); | ||
int opcion=-1; | ||
|
||
while(opcion!=0) { | ||
System.out.println("Escoja una opción:"); | ||
System.out.println("1. Mostrar información de película"); | ||
System.out.println("2. Mostrar información de intérprete"); | ||
System.out.println("3. Añadir voto a película"); | ||
|
||
System.out.println("0. Salir"); | ||
|
||
try { | ||
opcion = Integer.parseInt(sc.nextLine()); | ||
switch(opcion) { | ||
//TODO Gestionar excepciones | ||
|
||
case 1: | ||
System.out.println("Introduce el nombre de una película: "); | ||
String tituloPelicula = sc.nextLine(); | ||
catalogo.imprimirInfoPelicula(tituloPelicula); | ||
break; | ||
|
||
case 2: | ||
System.out.println("Introduce el nombre de un interprete: "); | ||
String nombreInterprete = sc.nextLine(); | ||
catalogo.imprimirInfoInterprete(nombreInterprete); | ||
break; | ||
|
||
case 3: | ||
System.out.println("Introduce el nombre de la película que deseas puntuar: "); | ||
tituloPelicula = sc.nextLine(); | ||
System.out.printf("Introduce la punctuation que quieres darle a %s :", tituloPelicula); | ||
float puntuacion = Float.parseFloat(sc.nextLine()); | ||
catalogo.anadirVoto(tituloPelicula, puntuacion); | ||
System.out.printf("Has votado a %s con un %s",tituloPelicula,puntuacion); | ||
|
||
break; | ||
|
||
default:break; | ||
} | ||
} | ||
catch(NumberFormatException e) | ||
{ | ||
System.out.println("#ERROR# Dato introducido no valido, Vuelve a Introducir el numero de la opción deseada. "); | ||
} | ||
catch(NoSuchElementException | IllegalStateException e) | ||
{ | ||
System.out.println("#ERROR# Imposible recorrer la linea"); | ||
} | ||
} | ||
sc.close(); | ||
|
||
|
||
} | ||
public static CatalogoIMDB catalogo; | ||
|
||
public static void main(String[] args) { | ||
catalogo = CatalogoIMDB.getInstance(); | ||
catalogo.cargarPeliculas("films.txt"); | ||
|
||
catalogo.cargarInterpretes("cast.txt"); | ||
|
||
//Menú | ||
|
||
Scanner sc = new Scanner(System.in); | ||
int opcion = -1; | ||
|
||
while (opcion != 0) { | ||
System.out.println("Escoja una opción:"); | ||
System.out.println("1. Mostrar información de película"); | ||
System.out.println("2. Mostrar información de intérprete"); | ||
System.out.println("3. Añadir voto a película"); | ||
|
||
System.out.println("0. Salir"); | ||
|
||
try { | ||
opcion = Integer.parseInt(sc.nextLine()); | ||
switch (opcion) { | ||
|
||
|
||
case 1: | ||
System.out.println("Introduce el nombre de una película: "); | ||
String tituloPelicula = sc.nextLine(); | ||
catalogo.imprimirInfoPelicula(tituloPelicula); | ||
break; | ||
|
||
case 2: | ||
System.out.println("Introduce el nombre de un interprete: "); | ||
String nombreInterprete = sc.nextLine(); | ||
catalogo.imprimirInfoInterprete(nombreInterprete); | ||
break; | ||
|
||
case 3: | ||
System.out.println("Introduce el nombre de la película que deseas puntuar: "); | ||
tituloPelicula = sc.nextLine(); | ||
System.out.printf("Introduce la punctuation que quieres darle a %s :", tituloPelicula); | ||
float puntuacion = Float.parseFloat(sc.nextLine()); | ||
catalogo.anadirVoto(tituloPelicula, puntuacion); | ||
System.out.printf("Has votado a %s con un %s", tituloPelicula, puntuacion); | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} catch (NumberFormatException e) { | ||
System.out.println("#ERROR# Dato introducido no valido, Vuelve a Introducir el numero de la opción deseada. "); | ||
} catch (NoSuchElementException | IllegalStateException e) { | ||
System.out.println("#ERROR# Imposible recorrer la linea"); | ||
} | ||
} | ||
sc.close(); | ||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters