Solución
solution.tsTypeScript
class Greeter:
# Atributo de clase para llevar el conteo de saludos
count: int = 0
# Agrega aquí el staticmethod que formatea el saludo
@staticmethod
def greet(name):
return {"greeting": f"Hola, {name}!", "count": Greeter.count_greet()}
# Agrega aquí el classmethod que incrementa count y usa el staticmethod
@classmethod
def count_greet(cls):
cls.count += 1
return (cls.count)
def greet_and_count(name: str) -> dict:
# Llama a Greeter.greet y retorna {"greeting": ..., "count": ...}
return Greeter.greet(name)0respuestas