Advertisement
Guest User

Untitled

a guest
Jan 31st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. import java.util.*;
  2. public class Utenza {
  3.     String user, password, nome, cognome;
  4.     Scanner scan;
  5.     public Utenza() {
  6.         user = password = nome = cognome = "";
  7.     }
  8.     public Utenza(String u, String p, String n, String c) {
  9.         user = u;
  10.         password = p;
  11.         nome = n;
  12.         cognome = c;
  13.     }
  14.    
  15.     public void inserisci() {
  16.         scan = new Scanner(System.in);
  17.         System.out.println("Nome: ");
  18.         nome = scan.nextLine();
  19.         System.out.println("Cognome: ");
  20.         cognome = scan.nextLine();
  21.         System.out.println("Username: ");
  22.         user = scan.nextLine();
  23.         System.out.println("Password: ");
  24.         password = scan.nextLine();
  25.     }
  26.     @Override
  27.     public String toString() {
  28.         return "Username: " + user + ", Password: " + password + ", Nome: " + nome + ", Cognome: " + cognome + " ";
  29.     }
  30.    
  31. }
  32.  
  33.  
  34. import java.util.*;
  35. public class Studenti extends Utenza{
  36.     String classe, indirizzo;
  37.     Scanner scan;
  38.     public Studenti() {
  39.         super();
  40.         classe = indirizzo = "";
  41.     }
  42.     public Studenti(String u, String p, String n, String c, String cl, String i) {
  43.         super(u,p,n,c);
  44.         classe = cl;
  45.         indirizzo = i;
  46.     }
  47.    
  48.     public void inserisci() {
  49.         super.inserisci();
  50.         scan = new Scanner(System.in);
  51.         System.out.println("Classe: ");
  52.         classe = scan.nextLine();
  53.         System.out.println("Indirizzo scolastico: ");
  54.         indirizzo = scan.nextLine();
  55.     }
  56.     @Override
  57.     public String toString() {
  58.         return super.toString() + "Classe: " + classe + ", Indirizzo: " + indirizzo + " ";
  59.     }
  60.    
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement