Skip to content

Instantly share code, notes, and snippets.

@sizzlemctwizzle
Created March 23, 2011 02:20
Show Gist options
  • Select an option

  • Save sizzlemctwizzle/882495 to your computer and use it in GitHub Desktop.

Select an option

Save sizzlemctwizzle/882495 to your computer and use it in GitHub Desktop.
Pseudocode for how the Qdoba Rewards Program works
// Sometimes I get bored and write Psuedocode for how random things work
// The following is pseudocode for how the Qdoba Rewards Program works
// How much money customer owes
amountDue = 0;
// Customers with Qdoba Cards earn points
if (customer.hasCard()) {
totalPoints = customer.pointTotal;
pointAmount = customer.isSignatureMember() ? 125 : 100;
}
// On Tuesdays you get double points
pointMultiplier = getDayOfWeek() == "Tuesday" ? 2 : 1;
// Use a stack to temporarily store the entrees
entrees = new Stack();
// Loop through each menu item that is being purchased
for (item in items) {
if (customer.hasCard() && item.isEntree()) {
// Each entree earns you 100 points (125 if Signature Member)
// Double points are earned on Tuesday
totalPoints += pointAmount * pointMultiplier;
// Push the entree onto the stack
entrees.push(item);
}
// The price of each item adds to the total
amountDue += item.price;
}
if (customer.hasCard()) {
// Keep giving free entree until we're either out of points
// or out of entrees being purchased
while (totalPoints >= 1100 && !entrees.isEmpty()) {
item = entrees.pop();
// Subtract the price of the item from the total
amountDue -= item.price;
// Subtract the amount of points used towards free entree
totalPoints -= 1100;
}
// Save the new point total of the customer
customer.pointTotal = totalPoints;
}
// Add the sales tax to the total
amountDue += amountDue * getTaxAsDecimal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment