I'm trying to create a program that simulates a season of baseball. It takes a text input from a file that has the stats of the player, like Batting Average, Fielding Percentage, Home Runs etc... So i have planned everything except the simulating part. I need to figure out a way to make the program have a way of giving the batter a Homerun, Single, Double, etc. One idea i got was that i could each batter have a random number for each stat, for example player xyz has a batting average of .333 so therefore we make a random number generator in the range between 1 and 3 then we would make an if statement that stated if the batting average of player xyz was 1 then he would get a hit. But there are many problems with this, the obvious one, a LOT of code for not a very complex task, another what if the batting average is another number like .280 then what number range would you use?
So i was wondering if anybody had a solution for this , or an easier way to do this.
qwesr 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.