Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public class Aluno
  2. {
  3. public String Nome { get; set; }
  4. public String Ra { get; set; }
  5. public Decimal NotaB1 { get; set; }
  6. public Decimal NotaB2 { get; set; }
  7.  
  8.  
  9. public Decimal getMedia()
  10. {
  11. return (NotaB1 + NotaB2) / 2;
  12. }
  13.  
  14. }
  15.  
  16. public class AlunoTecnologo : Aluno
  17. {
  18. public Decimal NotaPim { get; set; }
  19.  
  20. public Decimal getMedia()
  21. {
  22. return NotaPim * 0.2m + base.getMedia();
  23. }
  24. }
  25.  
  26. public class AlunoDao
  27. {
  28. private List<Aluno> alunos;
  29.  
  30. public AlunoDao()
  31. {
  32. alunos = new List<Aluno>();
  33. }
  34.  
  35. public void Adicionar(Aluno aluno)
  36. {
  37. alunos.Add(aluno);
  38. }
  39.  
  40. public List<Aluno> Listar()
  41. {
  42. return new List<Aluno>(alunos);
  43. }
  44. }
  45.  
  46. static void Main(string[] args)
  47. {
  48. Aluno vizu = new Aluno()
  49. {
  50. Nome = "Joao Vizu",
  51. Ra = "N300361",
  52. NotaB1 = 7.5M,
  53. NotaB2 = 10M
  54. };
  55.  
  56. AlunoTecnologo lais = new AlunoTecnologo()
  57. {
  58. Nome = "Lais Silva",
  59. Ra = "545454",
  60. NotaB1 = 7.5M,
  61. NotaB2 = 10M,
  62. NotaPim = 9M
  63. };
  64.  
  65. AlunoDao dao = new AlunoDao();
  66.  
  67. dao.Adicionar(vizu);
  68. dao.Adicionar(lais);
  69.  
  70. foreach (Aluno aluno in dao.Listar())
  71. {
  72. Console.WriteLine($"Nome: {aluno.Nome}tNotaB1: {aluno.NotaB1}tNotaB2: {aluno.NotaB2}tMedia: {aluno.getMedia()}");
  73. }
  74.  
  75. Console.ReadKey();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement