Java - Ayuda!!!

 
Vista:

Ayuda!!!

Publicado por Ana (1 intervención) el 28/02/2008 09:54:24
Si tengo este codigo como puedo terminar la opcion de modificar?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Agenda {
static InputStreamReader isr = new InputStreamReader(System.in);
static BufferedReader br = new BufferedReader(isr);
static Registro registros[];

public static void main(String[] args)throws IOException {
String opcion;
int i=0;
registros = new Registro [2];
for (i=0; i<registros.length; i++)
registros[i] = null;
System.out.println("1 - Añadir");
System.out.println("2 - Modificar");
System.out.println("3 - eliminiar");
System.out.println("4 - Buscar");
System.out.println("5 - Salir");
opcion = br.readLine();
while (!opcion.equals ("0")){
if (opcion.equals("1"))
agregar();
else if (opcion.equals("2"))
modificar ();
else if (opcion.equals("3"))
eliminar();
else if (opcion.equals("4"))
buscar();
else
System.out.println ("Opción incorrecta..");
System.out.println("1 - Añadir");
System.out.println("2 - Modificar");
System.out.println("3 - eliminiar");
System.out.println("4 - Buscar");
System.out.println("5 - Salir");
opcion = br.readLine();

}
}
static void agregar()throws IOException{
String nombre, localidad, calle, provincia;
int numero, piso, cp, i=0;
char letra;
long telefono;

while (registros [i] != null && i<registros.length)
i++;
if (i<registros.length){
System.out.print("Nombre: ");
nombre = br.readLine();
System.out.print("Calle: ");
calle = br.readLine();
System.out.print("Numero: ");
numero = Integer.parseInt(br.readLine());
System.out.print("Piso: ");
piso = Integer.parseInt(br.readLine());
System.out.print("Letra: ");
letra = br.readLine().charAt(0);
System.out.print("Codigo postal: ");
cp = Integer.parseInt(br.readLine());
System.out.print("Localidad: ");
localidad = br.readLine();
System.out.print("Provincia: ");
provincia = br.readLine();
System.out.print("Telefono: ");
telefono = Long.parseLong(br.readLine());
Direccion aux = new Direccion(calle, numero, piso,
letra, cp, localidad, provincia);
registros[i]= new Registro(nombre, aux, telefono);

}else
System.out.println("Datos añadidos a la agenda...");
if (i>registros.length)
System.out.print("la agenda esta llena");
}

static void modificar()throws IOException{
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder