Obviously, this is a bank-auto-upgrading system.
But: I'd like more condensed code.
Anyone think they can do something shorter?
<? public function upgrade(){ $types []= "Junior Saver"; $amounts [] = array(0, 1000); $types []= "Neopian Student"; $amounts [] = array(1001, 2500); $types []= "Bronze Saver"; $amounts [] = array(2501, 5000); $types []= "Silver Saver"; $amounts [] = array(5001, 10000); $types []= "Super Gold Plus"; $amounts [] = array(10001, 25000); $types []= "Platinum Extra"; $amounts [] = array(25001, 50000); $types []= "Double Platinum"; $amounts [] = array(50001, 75000); $types []= "Triple Platinum"; $amounts [] = array(75001, 100000); $types []= "Diamond Deposit"; $amounts [] = array(100001, 250000); $types []= "Diamond Deposit Plus"; $amounts [] = array(250001, 500000); $types []= "Diamond Deposit Gold"; $amounts [] = array(500001, 1000000); $types []= "Millionaire Platinum"; $amounts [] = array(1000001, 2000000); $types []= "Millionaire Double Platinum"; $amounts [] = array(2000001, 5000000); $types []= "Millionaire Mega-Platinum"; $amounts [] = array(5000001, 7500000); $types []= "Neopian Mega-Riches"; $amounts [] = array(7500001, 10000000); $types [] = "Ultimate Riches!"; end($types); // for error prevention because there is no "isBetweenRange" type for 10 mil, up to infinity $account_key = key($types); // gets the key for Ultimate Riches (for error prevention above) // Assume that $balance is any positive number while ($amount = current($amounts)) { if(isBetweenRange($balance, $amount[0], $amount[1])){ // I'm sure I don't have to put the function here...It's self-explanatory. $account_key = key($amounts); // will overwrite the Ultimate Riches (unless they're Ultimately Rich) o-o } next($amounts); } // Bank Changing Code, Hidden <img src='http://www.neocodex.us/forum/public/style_emoticons/<#EMO_DIR#>/biggrin.gif' class='bbc_emoticon' alt=':D' /> echo "Bank Account Changed To {$types[$account_key]}!";}
Good god, the editor here rapes my indenting.
Edited by sLAUGHTER, 28 July 2010 - 10:45 PM.