class Trabalho{
private String tipo, título, orientador
; private double nota;
this .t ítulo = título;
this .orientador = orientador;
this .nota = nota;
switch ( nível_curso)
{
case "Graduação (Bacharelado)" : tipo= "TCC" ; break ;
case "Lato sensu" : tipo = "Monografia" ; break ;
case "Mestrado" : tipo = "Dissertação" ; break ;
case "Doutorado" : tipo = "Tese" ; break ;
}
}
String resp
= "Título do trabalho (" + tipo
+ "): " ; resp += título + "\n " ;
resp += "Orientador(a): Prof. " + orientador + "\n " ;
resp += "Nota: " + nota + "\n " ;
return resp;
}
}
class TrabalhoNulo extends Trabalho{
public TrabalhoNulo( ) {
super ( null ,null ,- 1.0 ,"" ) ;
}
return "Obs: CST não têm obrigatoriedade de trabalho de conclusão\n " ;
}
}
class Curso{
private String nome_curso, nível_curso
; private double mensalidade_curso;
public Curso
( String nome_curso,
String nível_curso,
double mensalidade_curso
) { this .nome_curso = nome_curso;
this .n ível_curso = nível_curso;
this .mensalidade_curso = mensalidade_curso;
}
return "Curso: " + this .n ível_curso + " em " + this .nome_curso + "\n " ;
}
public double getMensalidade( ) {
return mensalidade_curso;
}
return nível_curso;
}
}
class Aluno{
private int cód_matrícula;
private boolean é_bolsista;
private double mensalidade_curso, desconto;
protected Curso curso;
private Trabalho trabalho;
Curso curso,
Trabalho trabalho,
int cód_matrícula,
boolean é_bolsista,
double desconto) {
this .nome = nome;
this .curso = curso;
this .trabalho = trabalho;
this .c ód_matrícula = cód_matrícula;
this .é_bolsista = é_bolsista;
this .desconto = desconto;
}
public String getMensalidadeFinal
( ) { if ( é_bolsista)
{
resp += "Bolsista com desconto de: " + this .desconto + "%\n " ;
resp += "Mensalidade: R$ " + curso.getMensalidade ( ) * ( 1 - this .desconto / 100 ) + "\n " ;
}
else resp += "Mensalidade: R$ " + curso.getMensalidade ( ) + "\n " ;
return resp;
}
{
String resp
= "Aluno: " + this .
nome + "\n " ; resp += curso.getDados ( ) ;
resp += this .getMensalidadeFinal ( ) ;
resp += trabalho.getDados ( ) ;
return resp;
}
}
class Teste
{
public static void main
( String args
[ ] ) {
Curso curso1 = new Curso ( "ADS" , "Graduação" , 920.50 ) ;
Trabalho trabalho1 = new TrabalhoNulo( ) ;
Curso curso2 = new Curso ( "Computação Aplicada" , "Mestrado" , 2150.45 ) ;
Trabalho trabalho2 = new Trabalho( "Peter Coad" ,"Impacto da Refatoração" ,9.5 ,curso2.getN ível( ) ) ;
Aluno a1 = new Aluno( "Martin Fowler" ,
curso1,
trabalho1,
11223344 ,
true ,
20.5 ) ;
Aluno a2 = new Aluno( "Kent Beck" ,
curso2,
trabalho2,
22334455 ,
false ,
0 ) ;
System .
out .
println ( a1.
getDados ( ) ) ; System .
out .
println ( a2.
getDados ( ) ) ; }
}
Y2xhc3MgVHJhYmFsaG97Cglwcml2YXRlIFN0cmluZyB0aXBvLCB0w610dWxvLCBvcmllbnRhZG9yOwoJcHJpdmF0ZSBkb3VibGUgbm90YTsKCXB1YmxpYyBUcmFiYWxobyAoU3RyaW5nIG9yaWVudGFkb3IsIFN0cmluZyB0w610dWxvLCBkb3VibGUgbm90YSwgU3RyaW5nIG7DrXZlbF9jdXJzbyl7CgkJdGhpcy50w610dWxvID0gdMOtdHVsbzsKCQl0aGlzLm9yaWVudGFkb3IgPSBvcmllbnRhZG9yOwoJCXRoaXMubm90YSA9IG5vdGE7CgkJc3dpdGNoIChuw612ZWxfY3Vyc28pCgkJCQl7CgkJCQkgY2FzZSAiR3JhZHVhw6fDo28gKEJhY2hhcmVsYWRvKSI6IHRpcG89ICJUQ0MiOyBicmVhazsKCQkJCSBjYXNlICJMYXRvIHNlbnN1IjogdGlwbyA9ICJNb25vZ3JhZmlhIjsgYnJlYWs7CgkJCQkgY2FzZSAiTWVzdHJhZG8iOiB0aXBvID0gIkRpc3NlcnRhw6fDo28iOyBicmVhazsKCQkJCSBjYXNlICJEb3V0b3JhZG8iOiB0aXBvID0gIlRlc2UiOyBicmVhazsKCQkJCX0KCX0KCXB1YmxpYyBTdHJpbmcgZ2V0RGFkb3MoKXsKC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