Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Persona
- {
- //PARAMETRI DELLA CLASSE
- String nome;
- String cognome;
- char sesso; //m o f
- //COSTRUTTORE
- public Persona (String unNome, String unCognome, char unSesso)
- {
- nome = unNome;
- cognome = unCognome;
- sesso = unSesso;
- }
- //METODI
- public void stampaPersona ()
- {
- System.out.println("Persona: " + nome + " " + cognome + " di sesso " + sesso);
- }
- public int contaCaratteriNome()
- {
- int caratteri = nome.length();
- return caratteri;
- }
- }
- /**
- *
- */
- /**
- * @author KiraChan
- *
- */
- public class Creatore
- {
- public static void main(String[] args)
- {
- Persona io = new Persona ("Luca", "bigliukTheory", 'm');
- Persona lei = new Persona ("Stefania", "Thava", 'F' );
- io.stampaPersona();
- lei.stampaPersona();
- int nIo= io.contaCaratteriNome();
- int nLei = lei.contaCaratteriNome();
- System.out.println(nIo);
- System.out.println(nLei);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement