issues
search
mchen10
/
coding-exercise
0
stars
1
forks
source link
Exercise 1 Adjustments
#7
Open
Studdyy
opened
4 years ago
Studdyy
commented
4 years ago
Description of Changes:
Created a Log Class to better document log entries
Changed location of ‘item_purchased_count’ to be within ‘process_logs’ since this is something that is reset daily
Consolidated the primary if / else statement as there was repeated logic unnecessarily
Performed all necessary computations within one loop of ‘items_purchased’ rather than multiple
Validated the ‘items_purchased’ list at the beginning of each for loop iteration to prevent execution of pointless code
Validated the value of ‘rewards_points_used’ and defaulted a value of 0
Included a list called ‘error’ to save all malfunctioned logs as the client requests.
Provided a variable for the value 17 instead of hard coding into logic
Incremented ‘total_sum’ by just item_price because I did not think ‘item_id’ should influence ’total_sum’
Incremented ‘item_count’ by 1 instead of ‘item_price’
Ensured that ‘rewards_points_used’ does not exceed the ‘rewards_points’ available for a specific customer
Ensured that ‘rewards_points_used’ does not exceed total_spent’
Devised a helper function to update rewards points system for modularity
Returned a tuple of the important information that the user may want after processing the daily logs
Removed unnecessary print statement which subjectively did not contribute to client intentions
Removed in function comments
Removed ‘get_items_purchased’ function since ‘item_purchased_count’ is no longer stored as a class variable
Abbreviated incrementation to += rather than including the ‘get’ call (The ‘defaultdict’ will ensure a default value of 0)
Rewrote some variable names for subjectively better readability
Moved library imports to the top of file
Wrote brief function and class documentation
Which files were touched:
'rewardsSystem.py'
Description of Changes:
Which files were touched: