Guest User

Untitled

a guest
Dec 11th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. public class usuario
  2. {
  3. static String nombre;
  4. static String tipo;
  5. static String pass;
  6.  
  7. public usuario(String nombre_, String tipo_,String pass_)
  8. {
  9. this.nombre=nombre_;
  10. this.tipo=tipo_;
  11. this.pass=pass_;
  12. }
  13. public String getNombre()
  14. {
  15. return this.nombre;
  16. }
  17. public String getTipo()
  18. {
  19. return this.tipo;
  20. }
  21. public String getPass()
  22. {
  23. return this.pass;
  24. }
  25. }
  26.  
  27. import javax.swing.*;
  28. import java.util.ArrayList;
  29. class principal
  30. {
  31. public static void main(String[] args)
  32. {
  33. String login;
  34. usuario[] bd_usuario=new usuario[3];
  35. JPasswordField jpf = new JPasswordField();
  36. JLabel titulo = new JLabel ("Ingrese su password");
  37. bd_usuario[0]=new usuario("Javier","admin","12345");
  38. bd_usuario[1]=new usuario("fernando","usuario","");
  39. bd_usuario[2]=new usuario("juan","usuario","");
  40. String usr;
  41. int option;
  42. usr=JOptionPane.showInputDialog(null,"ELIGA UNA OPCIONnt1.-Iniciar sesion ADMINISTRADORnt2.-Iniciar sesion USUARIO",JOptionPane.INFORMATION_MESSAGE);
  43. option=Integer.parseInt(usr);
  44. if (option==1)
  45. {
  46. int cs;
  47. String name;
  48. //String contra
  49. name=JOptionPane.showInputDialog(null,"Ingresa tu USUARIO");
  50.  
  51. JOptionPane.showConfirmDialog (null, new Object[]{titulo, jpf}, "Inicio de sesion", JOptionPane.OK_CANCEL_OPTION);
  52. char p[] = jpf.getPassword();
  53. String contra= new String(p);
  54. for(cs=0;cs<3;cs++){
  55. if(name==bd_usuario[cs].getNombre() /*&& contra==bd_usuario[cs].getPass()*/){
  56. m=v1.menu1();
  57. while(m>=1 && m<=7)
  58. {
  59. //demas funciones
Add Comment
Please, Sign In to add comment