Advertisement
Ecchijpbp

Programación 9-1

May 20th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. _______________________________________________________________________________________
  2. CLASE MASCOTA
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace Proyecto_Animales
  11. {
  12. class Mascota
  13. {
  14. private string nombre;
  15. private int edad;
  16. private int tipo;
  17. private Dueño dueño;
  18.  
  19. public int pEdad { get { return edad; } set { edad = value; } }
  20. public int pTipo { get { return tipo; } set { tipo = value; } }
  21. public string pNombre { get { return nombre; } set { nombre = value; } }
  22. public Dueño pDueño { get { return dueño; } set { dueño = value; } }
  23.  
  24. public Mascota()
  25. {
  26. nombre = "";
  27. edad = 0;
  28. tipo = 0;
  29. dueño = null;
  30. }
  31.  
  32. public Mascota(string nombre, int edad, int tipo, Dueño dueño)
  33. {
  34. this.nombre = nombre;
  35. this.edad = edad;
  36. this.tipo = tipo;
  37. this.dueño = dueño;
  38. }
  39.  
  40. public string toStringtipo()
  41. {
  42. switch(tipo){
  43. case 1: return "Perro";
  44. case 2: return "Gato";
  45. case 3: return "Ave";
  46. case 4: return "Roedor";
  47. default: return "Pickea tipo";
  48. }
  49. }
  50.  
  51. public string toStringMascota()
  52. {
  53. return "Datos Mascota: " + "\n" + "\n"
  54. + "Nombre: " + nombre + "\n"
  55. + "Edad: " + edad + "\n"
  56. + "Tipo: " + toStringtipo() + "\n"
  57. + "\n" + "\n"
  58. + "Datos Dueño: " + "\n" + "\n"
  59. + dueño.toStringDueño();
  60. }
  61. }
  62. }
  63. ____________________________________________________________________________________________
  64. CLASE DUEÑO
  65.  
  66. using System;
  67. using System.Collections.Generic;
  68. using System.Linq;
  69. using System.Text;
  70. using System.Threading.Tasks;
  71.  
  72. namespace Proyecto_Animales
  73. {
  74. class Dueño
  75. {
  76. private int codigo;
  77. private string nombre;
  78. private bool sexo;
  79.  
  80. public int pCodigo { get { return codigo; } set { codigo = value; } }
  81. public string pNombre { get { return nombre; } set { nombre = value; } }
  82. public bool pSexo { get { return sexo; } set { sexo = value; } }
  83.  
  84.  
  85. public Dueño()
  86. {
  87. codigo = 0;
  88. nombre = "";
  89. sexo = true;
  90. }
  91.  
  92. public Dueño(int codigo, string nombre, bool sexo)
  93. {
  94. this.codigo = codigo;
  95. this.nombre = nombre;
  96. this.sexo = sexo;
  97. }
  98.  
  99. public string toStringSexo()
  100. {
  101. if (sexo)
  102. return "Masculino";
  103. else
  104. return "Femenino";
  105. }
  106.  
  107. public string toStringDueño()
  108. {
  109. return "Código: " + codigo + "\n"
  110. + "Nombre: " + nombre + "\n"
  111. + "Sexo: " + toStringSexo() + "\n";
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement