Solución

@abrahamjlr
·hace 2dTypeScript
solution.tsTypeScript
STANDAR_PRICE = 80
DELUXE_PRICE = 150
SUITE_PRICE = 250
WEEKEND_SURCHARGE = 1.2

SILVER_DISCOUNT = 0.05
GOLD_DISCOUNT = 0.10
PLATINUM_DISCOUNT = 0.15


def get_base_price(room_type: str) -> int:
    if room_type == "standard":
        return STANDAR_PRICE
    elif room_type == "deluxe":
        return DELUXE_PRICE
    elif room_type == "suite":
        return SUITE_PRICE
    return 0


def calculate_hotel_stay_cost(nights: int, room_type: str, is_weekend: bool, loyalty_level: str) -> float:
    if nights < 1: 
        return -1

    base_nightly = get_base_price(room_type)

    if is_weekend:
        base_nightly *= WEEKEND_SURCHARGE

    total = nights * base_nightly

    if loyalty_level == "silver":
        total *= (1 - SILVER_DISCOUNT)
    elif loyalty_level == "gold":
        total *= (1 - GOLD_DISCOUNT)
    elif loyalty_level == "platinum":
        total *= (1 - PLATINUM_DISCOUNT)


    return total

exports = calculate_hotel_stay_cost
0respuestas
Respuestas
0

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.
Markdown