Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- POO
- 2 pacotes: Principal (classe Principal) e Entidades (classes: Paciente e Hospital)
- Apenas um exercício sobre POO
- */
- package Entidades;
- public class Paciente
- {
- private String nome;
- private short idade;
- private char sexo;
- private boolean internado;
- private Hospital hospital; //agregação com a class Hospital
- //Métodos
- public void alta()
- {
- internado = false;
- hospital = null;
- }
- public void internar(Hospital hospital)
- {
- internado = true;
- this.hospital = hospital;
- }
- public void status()
- {
- System.out.println("Paciente:" + getNome());
- System.out.println("Idade:" + getIdade());
- if(internado)
- {
- System.out.println("Internado: SIM");
- System.out.println("Hospital: "+getHospital().getNomeHospital());
- }
- else
- {
- System.out.println("Internado: NÃO");
- }
- }
- //getters and setters
- public String getNome()
- {
- return nome;
- }
- public void setNome(String nome)
- {
- this.nome = nome;
- }
- public short getIdade()
- {
- return idade;
- }
- public void setIdade(short idade)
- {
- this.idade = idade;
- }
- public char getSexo()
- {
- return sexo;
- }
- public void setSexo(char sexo)
- {
- this.sexo = sexo;
- }
- public boolean isInternado()
- {
- return internado;
- }
- private void setInternado(boolean internado)
- {
- this.internado = internado;
- }
- public Hospital getHospital()
- {
- return hospital;
- }
- private void setHospital(Hospital hospital)
- {
- this.hospital = hospital;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement