Вы находитесь на странице: 1из 5

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tarea;
import java.util.Scanner;
import javax.swing.JOptionPane;
/**
*
* @author Mockah
*/
class cuadrilla{
int idcua[];
String nombre[];

}
class detalle {
int id[];
int cod[];
int cant[];
}
class prestamos {
int id[];
String fecha[];
String cuadrilla [];

}
class arreglos {
String desc[],d;
int cant[],id[], p,tam,cod,can,i,pos,aux,aux2,dato;
int cont=-1;
Scanner sc=new Scanner(System.in);
void Inicializar(){
tam = Integer.parseInt(JOptionPane.showInputDialog(null,"INGRESE EL NUMERO DE AR
TICULOS:"));
int Aux[]=new int [tam];

for (i=0;i<tam;i++)
Aux [i]=0;
id=Aux;
cont=-1;
String aux2[]=new String[tam];
for (i=0;i<tam;i++)
aux2 [i]="";
desc=aux2;
cont=-1;
int aux3[]=new int [tam];
for (i=0;i<tam;i++)
aux3 [i]=0;
cant=aux3;
cont=-1;
}
boolean Arreglo_lleno()
{
if(cont==tam-1)
{
return true;
}
else
{
return false;
}
}
void Insertar_dato(){
if(Arreglo_lleno()==false) {
cont++;
//
cod = Integer.parseInt(JOptionPane.showInputDialog(null,"CLAVE:"));
id[cont]=cod;
d = JOptionPane.showInputDialog (null, "DESCRIPCION: ", "showInputDialog
",JOptionPane.INFORMATION_MESSAGE);
desc[cont]=d;
can = Integer.parseInt(JOptionPane.showInputDialog(null,"CANTIDAD:"));
cant[cont]=can;
}
//

else
System.out.println("lo siento,no hay espacio para este dato");
JOptionPane.showMessageDialog(null,"No hay espacio");

}
int Busqueda_Seq(){
if(Array_vacio()==true){

return -1;
}
for(i=0;i<=cont;i++)
if(cod==id[i])
return i;
return -2;
}
void Listar_Arreglo(){
pos = Busqueda_Seq();
if(pos==-1)
//
System.out.println("arreglo vacio");
JOptionPane.showMessageDialog(null,"Arreglo vacio");
else{

System.out.println("id \t \t
descripcion \t \t
cantidad");
for(i=0;i<tam;i++){
System.out.println(""+id[i]+ "\t\t\t"+desc[i]+"\t\t\t"+cant[i]);

}
}

}
boolean Array_vacio(){
if(cont==-1)
return true;
else
return false;
}
void Eliminar_Arreglo(){
pos = Busqueda_Seq();
if(pos==-1){
JOptionPane.showMessageDialog(null,"Arreglo vacio");
}
else if(Busqueda_Seq()>-1){
for(i=0;i<cont;i++)
id[i]=id[i+1];
cont--;
JOptionPane.showMessageDialog(null,desc[i]+"eliminada");

}
else JOptionPane.showMessageDialog(null,"DATO NO ENCONTRADO");
}
void Modificar_Arreglo(){
pos=Busqueda_Seq();
if(pos==-1){
//
System.out.println("arreglo vacio");
JOptionPane.showMessageDialog(null,"Arreglo vacio");
}
else if(pos>=0){
dato=Integer.parseInt(JOptionPane.showInputDialog(null,"nuevo codigo :")
);
cant[cont]=cant[i];
cont+=dato;
}
else JOptionPane.showMessageDialog(null,"DATO NO ENCONTRADO");
}
void Menu(){
int Opcion;
do{
Opcion = Integer.parseInt(JOptionPane.showInputDialog(null,
"1. INICIALIZAR\n"+
"2. DAR DE ALTA ARTICULOS\n"+
"3. ELIMINAR ARTICULOS (CODIGO)\n"+
"4. MODIFICAR ARTICULOS\n"+
"5. CONSULTAR\n"+
"6. VER CATALOGO\n"+
"7. Prestamo\n"+
"8. -------------\n"+
"9. Salir\n"+
"--------------------------------------------------------\n"
+
"INGRESE LA OPCION [1 - 7]",JOptionPane.QUESTION_MESSAGE));

switch(Opcion){
case 1:
Inicializar();
break;
case 2:
Insertar_dato();
break;
case 3:
cod = Integer.parseInt(JOptionPane.showInputDialog(null
,"CLAVE:"));

Eliminar_Arreglo();
break;
case 4:
cod=Integer.parseInt(JOptionPane.showInputDialog(null,"CODIG
O A MODIFICAR:"));

Modificar_Arreglo();

break;
case 5:
break;
case 6:
Listar_Arreglo();
break;
case 7:
break;
case 8:
break;
case 9:
System.exit(0);
break;
default: JOptionPane.showMessageDialog(null,"INGRESE UNA OPC
ION VALIDA \n","ERROR OPCION",JOptionPane.WARNING_MESSAGE);
}
}
while(true);
}
}

Вам также может понравиться