DriverJuego.java
Autores: Claudia Grajeda 10118
Juan Carlos Rosito 10043
Diego Yon 10070
Fecha: 20 de agosto de 2010
Descripcion: Driver (main)
*/
import java.util.*;
public class DriverJuego {
public static void main(String[] args) {
//Objetos
Scanner ingreso= new Scanner(System.in);
Juego juego;
Scores[] lista;
//Variables
String nombre;
int i=0, opcion=0,fil=-1,col=-1,cordenadaf1=-1,cordenadac1=-1,co
rdenadaf2=-1,cordenadac2=-1;
int acFila1,acColu1,acFila2,acColu2,puntosTot=0,turnos=0;
//Lista para los high scores
lista = new Scores[10];
for (int r= 0; r<lista.length;r++)
lista[r]=new Scores("------",0);
do{
menu();
opcion = (int)obtenerNumero ("Ingrese su opcion:
", false);
switch(opcion){
case 1:
System.out.println(Juego.getInst
rucciones());
break;
case 2:
//El usuario escoge la cantidad
de filas
do{
System.out.print
("\nIngrese la cantidad de filas: ");
try{
fil = in
greso.nextInt();
ingreso.
nextLine();
if (fil<
4 || fil > 9){
System.out.println("ERROR: Es recomendable que sea mayor que 3 y menor que 10.")
;
System.out.println("Intente de nuevo.\n");
}
}
catch(InputMisma
tchException exception){
System.o
ut.println("ERROR: Ingreso invalido. Intente de nuevo.\n");
ingreso.
nextLine();
}
}while(fil<4 || fil > 9)
;
//El usuario escoge la c
antidad de columnas
do{
System.out.print
("\nIngrese la cantidad de columnas: ");
try{
col = in
greso.nextInt();
ingreso.
nextLine();
if (col<
5|| col > 9){
System.out.println("ERROR: Es recomendable que sea mayor que 4 y menor que 10.")
;
System.out.println("Intente de nuevo.\n");
}
}
catch(InputMisma
tchException exception){
System.o
ut.println("ERROR: Ingreso invalido. Intente de nuevo.\n");
ingreso.
nextLine();
}
}while(col<5 || col > 9)
;
//Se crea el juego segun
la cantidad de filas y columnas
juego= new Juego(fil,col
);
//asignacion de cero
turnos=0;
puntosTot=0;
while(turnos<5){
//contador de tu
rnos
turnos++;
//imprime inicia
lmente el juego
System.out.print
ln(juego);
do{//Verificar s
i una esta a la par de la otra
do{//Ver
ificar si seleccionó la misma casilla
//Ingreso de la primera coordenada a cambiar
System.out.println("\nIngrese la primera coordenada del simbolo que desea cambia
r:");
do{
cordenadaf1=-1;
System.out.print("Fila: ");
try{
cordenadaf1 = ingreso.nextInt()-1;
ingreso.nextLine();
if (cordenadaf1<0 || cordenadaf1 > fil-1){
System.out.println("ERROR: No esta dentro de los parametros de la matriz.");
System.out.println("Intente de nuevo.\n");
}
}
catch(InputMismatchException exception){
System.out.println("ERROR: Ingreso invalido. Intente de nuevo.\n");
ingreso.nextLine();
}
}while(cordenadaf1<0 || cordenadaf1> fil-1);
do{
cordenadac1=-1;
System.out.print("Columna: ");
try{
cordenadac1 = ingreso.nextInt()-1;
ingreso.nextLine();
if (cordenadac1<0 || cordenadac1 > col-1){
System.out.println("ERROR: No esta dentro de los parametros de la matriz.");
System.out.println("Intente de nuevo.\n");
}
}
catch(InputMismatchException exception){
System.out.println("ERROR: Ingreso invalido. Intente de nuevo.\n");
ingreso.nextLine();
}
}while(cordenadac1<0 || cordenadac1> col-1);
do{
cordenadac2=-1;
System.out.print("Columna: ");
try{
cordenadac2 = ingreso.nextInt()-1;
ingreso.nextLine();
if (cordenadac2<0 || cordenadac2 > col){
System.out.println("ERROR: No esta dentro de los parametros de la matriz.");
System.out.println("Intente de nuevo.\n");
}
}
catch(InputMismatchException exception){
System.out.println("ERROR: Ingreso invalido. Intente de nuevo.\n");
ingreso.nextLine();
}
}while(cordenadac2<0 || cordenadac2> col);