Пример #1
0
def display_scheme_details(card_type, card_reward_details):
    if (validate_card_availability(card_type, card_reward_details)):

        card_type_list = card_reward_details[0]
        min_trasaction_amt_list = card_reward_details[1]
        reward_point_list = card_reward_details[2]
        for i in range(len(card_type_list)):
            if (card_type_list[i] == card_type):
                index = i
                break
        reward_point = reward_point_list[index]
        min_transaction_amt = min_trasaction_amt_list[index]
        print(
            " ---------------------------------------------------------------------"
        )
        print(
            "|      Card Type     |   Min. Transaction Amount   |   Reward Points  |"
        )
        print(
            " ---------------------------------------------------------------------"
        )
        print(
            "|" + " " * ((21 - len(card_type)) // 2) + card_type + " " *
            ((21 - len(card_type)) // 2) + "|",
            "             " + min_transaction_amt + "             |",
            "        " + reward_point + "        |")
        print(
            " ---------------------------------------------------------------------"
        )
    else:
        print("ERROR:Invalid Card Type ")
Пример #2
0
def delete_reward_scheme(card_type, card_reward_details_dict):
    if (card_reward_details_dict != None):
        if (validate_card_availability(card_type, card_reward_details_dict)):
            card_reward_details_dict.pop(card_type)
            return card_reward_details_dict
        else:
            print("ERROR:Invalid Card Type ")
            return -1
    else:
        print("Implement the given exercises"
              )  #Remove this print statement and write your code
Пример #3
0
def add_reward_scheme(card_type, min_transaction_amt, reward_point,
                      card_reward_details):
    if (not validate_card_availability(card_type, card_reward_details)):
        card_type_list = card_reward_details[0]
        min_trasaction_amt_list = card_reward_details[1]
        reward_point_list = card_reward_details[2]
        card_type_list.append(card_type)
        min_trasaction_amt_list.append(min_transaction_amt)
        reward_point_list.append(reward_point)
        return (card_type_list, min_trasaction_amt_list, reward_point_list)
    else:
        print("ERROR:Card Type is already available")
        return None
Пример #4
0
def delete_reward_scheme(card_type, card_reward_details):
    if (validate_card_availability(card_type, card_reward_details)):
        card_type_list = card_reward_details[0]
        min_trasaction_amt_list = card_reward_details[1]
        reward_point_list = card_reward_details[2]
        for i in range(len(card_type_list)):
            if (card_type_list[i] == card_type):
                index = i
                break
        card_type_list.pop(index)
        min_trasaction_amt_list.pop(index)
        reward_point_list.pop(index)
        return (card_type_list, min_trasaction_amt_list, reward_point_list)
    else:
        print("ERROR:Invalid Card Type ")
        return None
Пример #5
0
def calculate_reward_points(card_type, transaction_amt, card_reward_details):
    card_type_list = card_reward_details[0]
    min_trasaction_amt_list = card_reward_details[1]
    reward_point_list = card_reward_details[2]
    index = -1
    if (validate_card_availability(card_type, card_reward_details)):
        for i in range(len(card_type_list)):
            if (card_type_list[i] == card_type):
                index = i
                break
        reward_point = reward_point_list[index]
        min_transaction = min_trasaction_amt_list[index]
        total_reward_points = int(
            int(transaction_amt) * int(reward_point) / int(min_transaction))
        return total_reward_points
    else:
        print("ERROR:Invalid Card Type ")
        return None
Пример #6
0
def update_reward_scheme(card_type, min_transaction_amt, reward_point,
                         card_reward_details_dict):
    if (card_reward_details_dict != None):
        if (validate_card_availability(card_type, card_reward_details_dict)):
            if (int(min_transaction_amt) > 0):
                if (int(reward_point) > 0):
                    card_reward_details_dict[card_type] = [
                        min_transaction_amt, reward_point
                    ]
                    return card_reward_details_dict
                else:
                    print("ERROR: Invalid reward points")
                    return -1
            else:
                print("ERROR: Invalid min. transaction amount")
                return -1
        else:
            print("ERROR:Invalid Card Type ")
            return -1
    else:
        print("Implement the given exercises"
              )  #Remove this print statement and write your code
Пример #7
0
def update_customer_reward_points(customer_id, card_type, transaction_amt,
                                  card_reward_details, cust_reward_details):
    if (validate_details(customer_id, card_type, card_reward_details,
                         cust_reward_details)):

        cust_id_list = cust_reward_details[0]
        card_type_list = cust_reward_details[1]
        reward_point_list = cust_reward_details[2]
        reward_earned = calculate_reward_points(card_type, transaction_amt,
                                                card_reward_details)
        index = -1
        for i in range(len(cust_id_list)):
            if (cust_id_list[i] == customer_id):
                index = i
                break
        reward_point_list[index] = str(
            int(reward_point_list[index]) + int(reward_earned))
        print("Reward points for the transaction is:", reward_earned)
        return (cust_id_list, card_type_list, reward_point_list)
    elif (not validate_customer_id(customer_id, cust_reward_details)):
        if (validate_card_availability(card_type, card_reward_details)):
            cust_id_list = cust_reward_details[0]
            card_type_list = cust_reward_details[1]
            reward_point_list = cust_reward_details[2]
            reward_earned = calculate_reward_points(card_type, transaction_amt,
                                                    card_reward_details)
            cust_id_list.append(customer_id)
            card_type_list.append(card_type)
            reward_point_list.append(str(int(reward_earned)))
            print("Customer added successfully with Id", customer_id)
            print("Reward points for the transaction is:", reward_earned)
            return (cust_id_list, card_type_list, reward_point_list)
        else:
            print("ERROR:Invalid Card Type ")
            return None
    else:
        return None