Advertisement
tutorfree

Exerc02 - Pacote Entidades - classe Paciente

Aug 18th, 2015
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.79 KB | None | 0 0
  1. /*
  2.    POO
  3.    2 pacotes: Principal (classe Principal) e Entidades (classes: Paciente e Hospital)
  4.    Apenas um exercício sobre POO
  5. */
  6. package Entidades;
  7.  
  8. public class Paciente
  9. {
  10.     private String nome;
  11.     private short idade;
  12.     private char sexo;
  13.     private boolean internado;
  14.     private Hospital hospital; //agregação com a class Hospital
  15.  
  16.     //Métodos
  17.     public void alta()
  18.     {
  19.         internado = false;
  20.         hospital = null;
  21.     }
  22.    
  23.     public void internar(Hospital hospital)
  24.     {
  25.         internado = true;
  26.         this.hospital = hospital;
  27.     }
  28.    
  29.     public void status()
  30.     {
  31.         System.out.println("Paciente:" + getNome());
  32.         System.out.println("Idade:" + getIdade());
  33.         if(internado)
  34.         {
  35.             System.out.println("Internado: SIM");
  36.             System.out.println("Hospital: "+getHospital().getNomeHospital());
  37.         }
  38.         else
  39.         {
  40.             System.out.println("Internado: NÃO");
  41.         }
  42.     }
  43.    
  44.     //getters and setters
  45.     public String getNome()
  46.     {
  47.         return nome;
  48.     }
  49.     public void setNome(String nome)
  50.     {
  51.         this.nome = nome;
  52.     }
  53.  
  54.     public short getIdade()
  55.     {
  56.         return idade;
  57.     }
  58.     public void setIdade(short idade)
  59.     {
  60.         this.idade = idade;
  61.     }
  62.  
  63.     public char getSexo()
  64.     {
  65.         return sexo;
  66.     }
  67.     public void setSexo(char sexo)
  68.     {
  69.         this.sexo = sexo;
  70.     }
  71.  
  72.     public boolean isInternado()
  73.     {
  74.         return internado;
  75.     }
  76.     private void setInternado(boolean internado)
  77.     {
  78.         this.internado = internado;
  79.     }
  80.  
  81.     public Hospital getHospital()
  82.     {
  83.         return hospital;
  84.     }
  85.     private void setHospital(Hospital hospital)
  86.     {
  87.         this.hospital = hospital;
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement