Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Conversation

@constanceshi
Copy link
Collaborator

Changes to rewardsPointsSystem.py:

  • move import statement to the top of the code
  • change argument in item constructor to follow word_underscore naming convention (same as other variables)
  • assign a constant variable REWARDS_RATIO_ABOVE_THRESHOLD to 17 instead of using magic numbers
  • add an error log attribute to the rewards system
  • use log_entry properties via dot notation rather than array access
  • initialize rewards points to 0 if not present
  • if the log entry is not present, add the log to the error log and do not execute the rest of the for loop for this log entry
  • remove resetting of items purchased and raising a value error and instead use the above approach to append the log to the error list
  • remove multiplication of item id by item price when accumulating total spent
  • increment the dictionary counting the number of each item purchased by 1 instead of the item's id
  • only loop through items in items_purchased once, keeping the total_spent regardless of the customer and incrementing the dictionary keeping count of how many of each item is purchased
  • move the rewards points subtraction and amount_spent update into a loop that only runs if the customer has an id
  • remove print statement
  • loop through the rewards points customers by getting them from amount_spent.keys()
  • compare amount_spent[customer_id] to rewards_cutoff instead of just amount_spent (a dictionary)
  • use an if else loop in adding rewards points for customers rather than setting it twice if they have spent over the cutoff

Issues

Proposes changes addressing #1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants