Advertisement
Guest User

due

a guest
Jul 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1.  
  2. public class Persona
  3. {
  4. //PARAMETRI DELLA CLASSE
  5. String nome;
  6. String cognome;
  7. char sesso; //m o f
  8.  
  9. //COSTRUTTORE
  10. public Persona (String unNome, String unCognome, char unSesso)
  11. {
  12. nome = unNome;
  13. cognome = unCognome;
  14. sesso = unSesso;
  15.  
  16. }
  17.  
  18. //METODI
  19. public void stampaPersona ()
  20.  
  21. {
  22. System.out.println("Persona: " + nome + " " + cognome + " di sesso " + sesso);
  23. }
  24.  
  25. public int contaCaratteriNome()
  26. {
  27. int caratteri = nome.length();
  28. return caratteri;
  29.  
  30.  
  31. }
  32.  
  33.  
  34.  
  35. }
  36.  
  37.  
  38.  
  39.  
  40. /**
  41. *
  42. */
  43.  
  44. /**
  45. * @author KiraChan
  46. *
  47. */
  48. public class Creatore
  49. {
  50. public static void main(String[] args)
  51. {
  52. Persona io = new Persona ("Luca", "bigliukTheory", 'm');
  53. Persona lei = new Persona ("Stefania", "Thava", 'F' );
  54.  
  55. io.stampaPersona();
  56. lei.stampaPersona();
  57.  
  58. int nIo= io.contaCaratteriNome();
  59. int nLei = lei.contaCaratteriNome();
  60.  
  61. System.out.println(nIo);
  62. System.out.println(nLei);
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement