File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes Baseball Simulator, Classes Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Baseball Simulator, Classes Issue" Watch "Baseball Simulator, Classes Issue" New topic

Baseball Simulator, Classes Issue

David McMonigle

Joined: Oct 07, 2013
Posts: 24

Hello all! Still new to the forums, so first greetings to all:

I'm still (semi)new to Java, and I've been working on a Baseball Simulator, well, designing first, but I'm having some issues working out the design. The simulator is really just going to take two teams and simulate each at-bat. Here's the design so far:

Simulate each at-bat, iterating innings, outs, runs, various outs/hits/walks.

Average out Pitcher OBP and Batter OBP to calculate probability of individual batter getting on basse
1.) Calculate Batter Hit percentage/ ExtraBase Percentage/ DoubleTriple Percentage/ Triple Percentage. etc
2.) Math.random() to determine these probabilities.

Add outs, move runners, add runs, iterate innings.

That's really the main idea, although the issue is this: I have a Super class in mind (BallPlayer) that will have two child classes (Batter and Pitcher). I'm wondering how I can go about making them go have an at-bat. Would an interface work to my advantage here?

Any advise would be much appreciated!

There's no such thing as a failure who keeps trying. Coasting to the bottom is the only disgrace
Coder's Nook - Learn What I Learn
subject: Baseball Simulator, Classes Issue
It's not a secret anymore!