tags:

views:

69

answers:

1

how do i model a baseball game and players in OO?

+1  A: 

You need to just think about the objects you want to mirror from the real world which could include:

  • players.
  • teams.
  • games (if more than one).
  • innings.
  • balls.
  • strikes.
  • outs.
  • home runs.

Really, there are a huge number of possibilities. It may be better to break down your proposal into use cases and work from those. A use case is simply a real-world example of the behaviour you want to model, an example being: what are the possible outcomes when a hitter takes a swing, and what are they based on?

For example, maybe the only thing you want to model is something simple like a random player coming to the plate and either striking out or hitting a home run (unlikely in a real game). That makes things very simple, no need to track individual players or what base they're on and so forth.

Or maybe you want to go to the other end of the scale and accurately match the pitcher and fielders against the hitter to see the likely outcome, and also allow one, two or three-base results (tracking each hitter until they reach home or are tagged out, if that's the right term). Then you'll need to store all sorts of statistics about every player on both teams.

paxdiablo
Thank you! I think I will start with the gameplay objects