Advertisement
adaptingear

pruebassad

Oct 9th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. class StudentClass:
  2.     #ATRIBUTOSS DE LAS CLASE
  3.     matricula=""
  4.     nombre=""
  5.     telefono=""
  6.     edad=""
  7.     peso=0.0
  8.  
  9.  
  10.     #METODOS
  11.     def _init_(self, matricula, nombre):
  12.         self.matricula=matricula
  13.         self.nombre=nombre
  14.  
  15.         #Retorna cada dato, cada vez que acceda a ellos
  16.     def getMatricula(self):
  17.         return self.matricula
  18.  
  19.     def getNombre(self):
  20.         return self.nombre
  21.  
  22.     def getTelefono(self):
  23.         return self.telefono
  24.  
  25.     def getEdad(self):
  26.         return self.edad
  27.  
  28.     def getPeso(self):
  29.         return self.peso
  30.  
  31.         #Recibe informacion, para luego almacenarla
  32.  
  33.     def setNombre(self, nombre):
  34.         self.nombre = nombre
  35.  
  36.     def setTelefono(self, telefono):
  37.         self.telefono=telefono
  38.  
  39.     def setEdad(self, edad):
  40.         self.edad = edad
  41.  
  42.     def setPeso(self, peso):
  43.         self.peso = peso
  44.  
  45.  
  46.  
  47.     def obtenerdatos(self):
  48.       while True:
  49.         print("-----MENU-----\n")
  50.         print("1. AGREGAR ESTUDIANTE")
  51.         print("2. MODIFICAR DATOS")
  52.         print("3. VER DATOS DEL ESTUDIANTE")
  53.         print("4. SALIR")
  54.         opcion = input("Selecciona una opcion: ")
  55.         if(opcion=="1"):
  56.             print("Escribe los datos del estudiante")
  57.             a = input("Nombre: ")
  58.             self.setNombre(a)
  59.             b = input("Matricula: ")
  60.             self.matricula = b
  61.         elif(opcion=="2"):
  62.             while(True):
  63.                 print("-----MENU PARA MODIFICAR-----\n")  
  64.                 print("1. ACTUALIZAR TELEFONO")
  65.                 print("2. ACTUALIZAR EDAD")
  66.                 print("3. ACTUALIZAR PESO")
  67.                 print("4. REGRESAR AL MENU ANTERIOR")
  68.                 opcion2 = input("Selecciona una opcion: ")
  69.                 if(opcion2=="1"):                
  70.                     c=input("Telefono:_")
  71.                     self.setTelefono(c)
  72.                 elif(opcion2=="2"):                    
  73.                     d = input("Edad:_")
  74.                     self.setEdad(d)
  75.                 elif(opcion2=="3"):
  76.                     e = input("Peso:_")
  77.                     self.setPeso(e)
  78.                 elif(opcion2=="4"):
  79.                     break;
  80.                 else:
  81.                     print("Opcion no valida")
  82.    
  83.         elif(opcion=="3"):
  84.             print("DATOS DEL ESTUDIANTE: ")
  85.             #print("Matricula: " + self.getMatricula())
  86.             print("Nombre: " + self.getNombre())
  87.             print("Matricula: " + self.getMatricula())
  88.             print("Telefono: " + self.getEdad())
  89.             print("Edad "+ self.getEdad())
  90.             print("Peso: "+ self.getPeso())
  91.  
  92.  
  93.         elif(opcion=="4"):
  94.             self.obtenerdatos()
  95.         else:
  96.             print("Opcion no valida")
  97.  
  98.  
  99. a = StudentClass()
  100. a.obtenerdatos()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement