Well here it is...
Any comments would be appreciated, thank you.#!/usr/bin/perl -w use strict; my($dif,$randNumber,$manip,$whichstock,$howmany,$goal,$date,$derpco,$t +etrabytz,$mojoinc,$freke,$mega,$cash,@stocks,$buy,$sell,$buynum,$sell +num,$trans); @stocks = (0,0,0,0,0); sub genRand { my $startNumber = shift(); my $endNumber = shift(); my $randNumber = int($startNumber + rand() * ($endNumber - $startNumbe +r)); return $randNumber; }; print "What Goal In Cash Do You Want To Set? :"; chomp ($goal=<STDIN>); print "Thanks\n\n"; $date=1; $derpco=genRand(10,100); $tetrabytz=genRand(10,100); $mojoinc=genRand(10,100); $freke=genRand(10,100); $mega=genRand(10,100); $cash=genRand(500,1000); until ($cash > $goal or $date == 31) { $date=$date+1; $manip=genRand(0,50); $derpco=$derpco+genRand(-10,10); $tetrabytz=$tetrabytz+genRand(-40,40); $mojoinc=$mojoinc+genRand(-20,20); $freke=$freke+genRand(-25,25); $mega=$mega+genRand(-35,35); if ($derpco < 1){$derpco = 0; $stocks[0]=0; }; if ($tetrabytz < 1){$tetrabytz = 0; $stocks[1]=0;}; if ($mojoinc < 1){$mojoinc = 0; $stocks[2]=0;}; if ($freke < 1){$freke = 0; $stocks[3]=0;}; if ($mega < 1){$mega = 0; $stocks[4]=0;}; if ($date == 30) {print "Last Day!! better sell your stock"}; if ($manip == 5) {print "there is a small market error in your favor!\ +n\n"; $whichstock=genRand(0,4); $howmany=genRand(1,10); $stocks[$whichstock]=$stocks[$whichstock]+$howmany;}; print "\n\nYour Stock Report for January $date\n\n"; print "Company You Own Value\n"; print "DerpCo $stocks[0] \$$derpco\n"; print "Tetrabytz $stocks[1] \$$tetrabytz\n"; print "MojoInc $stocks[2] \$$mojoinc\n"; print "Freke $stocks[3] \$$freke\n"; print "Mega $stocks[4] \$$mega\n"; print " you have \$$cash\n"; print "Would you like to (B)uy or (S)ell? "; $trans=<STDIN>; if ($trans =~/S/i) { print "What Stock would you like to Sell? "; chomp ($sell=<STDIN>); if ($sell =~/derp/i){ print "\nyou have $stocks[0] stocks in DerpCo\n"; print "Sell How many? :"; chomp ($sellnum=<STDIN>); if ($sellnum > $stocks[0] or $sellnum == 0) {print "Nice try\n"} else {$stocks[0]=$stocks[0]-$sellnum; $cash=$sellnum*$derpco;}; }; if ($sell =~/tet/i){ print "\nyou have $stocks[1] stocks in TetraBytz\n"; print "Sell How many? :"; chomp ($sellnum=<STDIN>); if ($sellnum > $stocks[1] or $sellnum == 0) {print "Nice try\n"} else {$stocks[1]=$stocks[1]-$sellnum; $cash=$sellnum*$tetrabytz;}; }; if ($sell =~/Mojo/i){ print "\nyou have $stocks[2] stocks in Mojo Inc\n"; print "Sell How many? :"; chomp ($sellnum=<STDIN>); if ($sellnum > $stocks[2] or $sellnum == 0) {print "Nice try\n"} else {$stocks[2]=$stocks[2]-$sellnum; $cash=$sellnum*$mojoinc;}; }; if ($sell =~/Freke/i){ print "\nyou have $stocks[3] stocks in Freke\n"; print "Sell How many? :"; chomp ($sellnum=<STDIN>); if ($sellnum > $stocks[3] or $sellnum == 0) {print "Nice try\n"} else {$stocks[3]=$stocks[3]-$sellnum; $cash=$sellnum*$freke;}; }; if ($sell =~/Mega/i){ print "\nyou have $stocks[4] stocks in Mega\n"; print "Sell How many? :"; chomp ($sellnum=<STDIN>); if ($sellnum > $stocks[4] or $sellnum == 0) {print "Nice try\n"} else {$stocks[4]=$stocks[4]-$sellnum; $cash=$sellnum*$mega;}; }; }; if ($trans =~/B/i) { print "What Stock would you like to buy? "; chomp ($buy=<STDIN>); if ($buy =~/derp/i){ print "\nyou have $stocks[0] stocks in DerpCo and \$$cash\n"; print "buy How many? :"; chomp ($buynum=<STDIN>); if ($cash < $derpco*$buynum) {print "Not enough cash\n"} else {$stocks[0]=$stocks[0]+$buynum; $cash=$cash-($buynum*$derpco)}; }; if ($buy =~/tet/i){ print "\nyou have $stocks[1] stocks in TetraBytz and \$$cash\n"; print "buy How many? :"; chomp ($buynum=<STDIN>); if ($cash < $tetrabytz*$buynum ) {print "Not enough cash\n"} else {$stocks[1]=$stocks[1]+$buynum; $cash=$cash-($buynum*$tetrabytz)} +; }; if ($buy =~/Mojo/i){ print "\nyou have $stocks[2] stocks in Mojo Inc and \$$cash\n"; print "buy How many? :"; chomp ($buynum=<STDIN>); if ($cash < $mojoinc*$buynum) {print "Not enough cash\n"} else {$stocks[2]=$stocks[2]+$buynum; $cash=$cash-($buynum*$mojoinc)}; }; if ($buy =~/Freke/i){ print "\nyou have $stocks[3] stocks in Freke and \$$cash\n"; print "Buy How many? :"; chomp ($buynum=<STDIN>); if ($cash < $freke*$buynum) {print "Not enough cash\n"} else {$stocks[3]=$stocks[3]+$buynum; $cash=$cash-($buynum*$freke)}; }; if ($buy =~/Mega/i){ print "\nyou have $stocks[4] stocks in Mega and \$$cash\n"; print "buy How many? :"; chomp ($buynum=<STDIN>); if ($cash < $mega*$buynum) {print "Not enough cash\n"} else {$stocks[4]=$stocks[4]+$buynum; $cash=$cash-($buynum*$mega)}; }; }; }; if ($cash > $goal) { $dif = $cash-$goal; print "Yay! you won, you beat your goal by \$$dif\n"; }; if ($cash < $goal) { $dif = $goal-$cash; print "Boo! you lost, you missed your goal by \$$dif\n"; };
In reply to Seeking Feed Back on a Game by Cobo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |