Last active
May 8, 2020 03:14
-
-
Save bitfishxyz/498c6419b55d20513c337104f9de5efc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'the apple purchase process begins'; | |
// try to visit these 3 fruit stores in turn | |
for(fruitStore of [fruitStroe0, fruitStroe1, fruitStroe2]){ | |
'start visiting the fruit store'; | |
'walk to the fruit shop'; | |
if('the fruit store was not open'){ | |
'stop the process of visiting the fruit store'; | |
} | |
if('the fruit store did not have apples'){ | |
'stop the process of visiting the fruit store'; | |
} | |
if('there is less than one kilogram of red apples left in the fruit shop'){ | |
'stop the process of visiting the fruit store'; | |
} | |
if('the price of red apples in this fruit store is over $10 per kilogram'){ | |
'ask the shopkeeper if he would like to reduce the price to $10/kg or less'; | |
if('the shopkeeper refused to reduce the price') { | |
'stop the process of visiting the fruit store'; | |
} | |
} | |
'open a bag and make it the current bag'; | |
while('the apples in this bag weigh less than 1 kilogram'){ | |
'choose the best of all the red apples that are not in the bag'; | |
if('this apple can fit into the current bag'){ | |
'load this apple into the current bag'; | |
} else { | |
// switch the bag | |
if('I still have some spare bags') { | |
'pick one of these and make it the current bag'; | |
} else { | |
try('ask the shopkeeper for a bag') { | |
'take the bag the shopkeeper gave me as the current bag'; | |
} catch ('the shopkeeper refused to give me the bag') { | |
'take all the apples out of all my bags'; | |
'stop the process of visiting the fruit store'; | |
} | |
} | |
} | |
} | |
'based on the total weight of all the apples in all my bags and \ | |
the unit price given by the store owner, calculate the price I should pay' | |
'ask the shopkeeper for my share of the money' | |
if('the price I calculated' == 'the price given by the shopkeeper') { | |
'pay the money to the shopkeeper'; | |
} else { | |
'recalculate the price of the apples'; | |
'explain the price I have calculated to the shopkeeper and ask him if he agrees'; | |
if('he agrees'){ | |
'pay the money to the shopkeeper'; | |
} else { | |
'take all the apples out of all my bags'; | |
'stop the process of visiting the fruit store'; | |
} | |
} | |
'complete the purchase process and take away all the apples'; | |
'stop visiting other fruit shops'; | |
} | |
'the apple purchase process ends'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment