Guest User

Untitled

a guest
Dec 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. public class Aplicacao {
  2.  
  3.     /**
  4.      * @param args
  5.      */
  6.     public static void main(String[] args) {
  7.  
  8.         String nome=JOptionPane.showInputDialog("Nome: ");
  9.         int idade=Integer.parseInt(JOptionPane.showInputDialog("Idade: "));
  10.        
  11.         Pessoa pessoa=new Pessoa(nome,idade);
  12.         int opcao;
  13.         do
  14.         {
  15.         opcao=Integer.parseInt(JOptionPane.showInputDialog(null, "Escolha: \n1-Cadastrar Filho \n2-Imprimir dados do Filho \n3-Sair "));
  16.        
  17.         switch (opcao)
  18.         {
  19.        
  20.         case 1:
  21.             String filho=JOptionPane.showInputDialog("Nome do 1° filho: ");
  22.             String filho2=JOptionPane.showInputDialog("Nome do 2° filho: ");
  23.             String filho3=JOptionPane.showInputDialog("Nome do 3° filho: ");
  24.             pessoa.CadastrarFilho(new Pessoa(filho,2));
  25.             pessoa.CadastrarFilho(new Pessoa(filho2,4));
  26.             pessoa.CadastrarFilho(new Pessoa(filho3,5));
  27.            
  28.             break;
  29.            
  30.         case 2:
  31.             System.out.println(pessoa.toString());
  32.          break;
  33.  
  34.         default:
  35.         System.out.println("Opção invalida!!!");
  36.             break;
  37.         }
  38.        
  39.        
  40.         }
  41.         while(opcao==1||opcao==2);
  42.        
  43.        
  44.     }
  45.  
  46. }
Add Comment
Please, Sign In to add comment