This document contains the code for a Java class called Metod that implements methods for adding, removing, modifying, and displaying user data stored in a 2D string array. The class contains methods to add new user data by prompting the user to input values for different data fields, remove a user by their name, modify an existing user's data by prompting for updated field values, and display all stored user data.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
43 views1 page
AgendaSimple PDF
This document contains the code for a Java class called Metod that implements methods for adding, removing, modifying, and displaying user data stored in a 2D string array. The class contains methods to add new user data by prompting the user to input values for different data fields, remove a user by their name, modify an existing user's data by prompting for updated field values, and display all stored user data.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
1 / *
2 * To change t hi s t empl at e, choose Tool s | Templ at es
3 * and open t he t empl at e i n t he edi t or . 4 * / 5 package pr act i ca; 6 7 i mpor t j avax. swi ng. JOpt i onPane; 8 i mpor t j ava. i o. * ; 9 / * * 10 * 11 * @aut hor Razt ek187 12 * / 13 publ i c cl ass Met od i mpl ement s Ser i al i zabl e { 14 St r i ng[ ] [ ] BD = new St r i ng[ 10] [ 4] ; 15 St r i ng[ ] Dat ={ " No" , " Nombr e" , " Apel l i dos" , " Tel ef ono" } ; 16 17 publ i c voi d Al t a( ) { 18 f or ( i nt i =0; i <BD. l engt h; i ++) { 19 i f ( BD[ i ] [ 0] ==nul l ) { 20 f or ( i nt j =0; j <BD[ 0] . l engt h; j ++) { 21 BD[ i ] [ j ] =JOpt i onPane. showInputDialog( nul l , " I ngr esa el si gui ent e dat o: " +Dat [ j ] ) ; 22 } 23 br eak; 24 } 25 } 26 27 } 28 publ i c voi d Baj a( ) { 29 St r i ng bNom=JOpt i onPane. showInputDialog( nul l , " I ngr ese el nombr e del usuar i o a dar de baj a" ) ; 30 i nt bRes=0; 31 f or ( i nt i =0; i <BD. l engt h; i ++) { 32 i f ( BD[ i ] [ 0] ! =nul l ) { 33 bRes=bNom. compar eToI gnor eCase( BD[ i ] [ 1] ) ; 34 i f ( bRes==0) { 35 f or ( i nt j =0; j <BD[ 0] . l engt h; j ++) { 36 BD[ i ] [ j ] =nul l ; 37 } 38 br eak; 39 } 40 } 41 } 42 } 43 publ i c voi d Modi f i car ( ) { 44 St r i ng mNom=JOpt i onPane. showInputDialog( nul l , " I ngr ese No. de usuar i o que qui er a modi f i car " ) ; 45 i nt mRes=0; 46 f or ( i nt i =0; i <BD. l engt h; i ++) { 47 i f ( BD[ i ] [ 0] ! =nul l ) { 48 mRes=mNom. compar eToI gnor eCase( BD[ i ] [ 0] ) ; 49 i f ( mRes==0) { 50 f or ( i nt j =0; j <BD[ 0] . l engt h; j ++) { 51 BD[ i ] [ j ] =JOpt i onPane. showInputDialog( nul l , " I ngr esa el si gui ent e dat o: " +Dat [ j ] ) ; 52 } 53 br eak; 54 } 55 } 56 } 57 } 58 publ i c voi d Most r ar ( ) { 59 St r i ng mDat =" " ; 60 i nt op=0; 61 f or ( i nt i =0; i <BD. l engt h; i ++) { 62 f or ( i nt j =0; j <BD[ 0] . l engt h; j ++) { 63 i f ( BD[ i ] [ j ] ! =nul l ) { 64 mDat +=BD[ i ] [ j ] +" " ; 65 } 66 } 67 i f ( BD[ i ] [ 0] ! =nul l ) { 68 mDat +=" \ n" ; 69 } 70 } 71 JOpt i onPane. showMessageDialog( nul l , mDat ) ; 72 } 73 } 74 C:\Users\Raztek187\Documents\NetBeansProjects\Practica\src\practica\Metod.java Pgina1 de1 Metod.java 11/06/2014 file:///C:/Users/Raztek187/Desktop/Metod.html