davegimo

francesco1

Mar 1st, 2021
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public class Persona {
  2.  
  3.     //variabili di persona
  4.  
  5.     private String nome;
  6.     private String cognome;
  7.     private int eta;
  8.  
  9.     public Persona(String n, String c, int e) {
  10.         this.nome = n;
  11.         this.cognome = c;
  12.         this.eta = e;
  13.     }
  14.  
  15.     public String getNome(){
  16.         return this.nome;
  17.     }
  18.  
  19.     public void setNome(String n){
  20.         this.nome = n;
  21.     }
  22.  
  23.     public String getCognome() {
  24.         return this.cognome;
  25.     }
  26.  
  27.     public void setCognome(String c) {
  28.         this.cognome = c;
  29.     }
  30.  
  31.     public int getEta() {
  32.         return this.eta;
  33.     }
  34.  
  35.     public void setEta(int e) {
  36.         this.eta = e;
  37.     }
  38.  
  39.  
  40.  
  41.     public static void main(String[] args) {
  42.  
  43.         System.out.println("");
  44.  
  45.  
  46.         Persona fra = new Persona("Francesco", "D'Amico", 22);
  47.         fra.setNome("ciccio");
  48.         System.out.println(fra.getNome());
  49.         System.out.println(fra.cognome);
  50.         System.out.println(fra.eta);
  51.        
  52.  
  53.  
  54.         System.out.println("");
  55.  
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment