diff --git a/README.md b/README.md index fa0237d..9d84e1a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # OpenBootCampPython Repository to store Python boot camp. + +Ejercicio 6.B: En este segundo ejercicio, tendréis que crear un programa que tenga una clase llamada Alumno que tenga como atributos su nombre y su nota. Deberéis de definir los métodos para inicializar sus atributos, imprimirlos y mostrar un mensaje con el resultado de la nota y si ha aprobado o no. diff --git a/src/exercisesix/alumno.py b/src/exercisesix/alumno.py new file mode 100644 index 0000000..6f9d466 --- /dev/null +++ b/src/exercisesix/alumno.py @@ -0,0 +1,48 @@ +class Alumno: + """Conceptual representation of a student + """ + def __init__(self, nombre='', nota=-1): + """Constructor method + :param nombre: student name + :type nombre: str + :param nota: student mark + :type nota: float + """ + self.nombre = nombre + self.nota = float(nota) + + def asignarNombre(self, nombre=''): + """Method to assign a student name + :param nombre: student name + :type nombre: str + :return: None + :rtype: NoneType + """ + self.nombre = nombre + + def asignarNota(self, nota=-1): + """Method to assign a student mark + :param nota: student mark + :type nota: float + :return: None + :rtype: NoneType + """ + self.nota = float(nota) + + def verDatos(self): + """Method to show student data + :return: None + :rtype: NoneType + """ + print('Alumno:', self.nombre) + print('Calificacion:', self.nota) + + def estaAprovado(self): + """Method to check if the student pass or fail + :return: None + :rtype: NoneType + """ + if self.nota >= 5: + print('Aprobado') + else: + print('Suspenso') diff --git a/src/main.py b/src/main.py index a47b6a3..3b17f06 100644 --- a/src/main.py +++ b/src/main.py @@ -1,9 +1,16 @@ +from src.exercisesix.alumno import Alumno + + def main(): - """Main script for pythonBootCamp project + """Main script for exercise six.b :return: None :rtype: NoneType """ - pass + alumno = Alumno() + alumno.asignarNombre('Rafael') + alumno.asignarNota(10) + alumno.verDatos() + alumno.estaAprovado() if __name__ == '__main__':