Question
!!JAVA PSEUDO CODE!! The objective of this assignment is to gain experience writing classes that conform to a set of requirements and using those methods
!!JAVA PSEUDO CODE!!
The objective of this assignment is to gain experience writing classes that conform to a set of requirements and using those methods in a program. Topics included in this project are: ArrayLists, Classes, Encapsulation, and Java basics. Your task is to simulate an entire baseball game. First you will write a program to simulate a batter facing a pitcher in a baseball game. Your program should include a Batter class with the following fields and methods: private String name private double average /* Assumes the pitcher has thrown a strike, uses this batters average to determine whether he hits the pitch (method returns true) or swings and misses (method returns false). */ public boolean hit() public String getName() // returns the Batters name You will also need to write a Pitcher class with the following fields and methods: private String name private double average /* Uses this pitchers average to determine whether he throws a strike (method returns true) or a ball (method returns false). */ public boolean pitch() 1 public String getName() // returns the Pitchers name You will then need to write a driver program that instantiates a two Pitcher (one per team) objects and nine Batter objects for each team and simulates a baseball game. The rules for this simulation are as follows: If a Pitchers average is, for example, .80 then 80 percent of the time calling the Pitcher classs pitch method should return true and 20 percent of the time it should return false. The Batter never swings at a ball and he always swings at a pitch in the strike zone. If the pitch is in the strike zone, the Batters hit method should be called. If the Batters average is .25 then 25 percent of the time, that method should return true (indicating a hit) and 75 percent of the time it should return false (indicating a swing and a miss).If the Batters name is John Doe and he gets a hit, your driver program should display the message John Doe got a hit! Your driver program should keep track of the number of balls and strikes. If the number of balls reaches four, the program should display the message John Doe walked. If the number of strikes reaches three, it should display the message John Doe struck out. After each pitch, your program should display the number of balls and strikes. There are 3 outs for each team in each inning. And every hit should be a single. If there is an out no one moves bases if there is a hit everyone moves bases. A point is scored when a batter reaches home plate (after 4 hits including their own). The bottom of the ninth inning (the home teams last 3 outs) does not get played if the home team is already winning.
Sample Runs
Top of Inning 1 Home: 0 Away: 0
Jackie throwing to T2 Batter 1 - Outs: 0
On First: false | On Second: false | On Third: false
Strike - Balls: 0 Strikes: 1
Ball - Balls: 1 Strikes: 1
Strike - Balls: 1 Strikes: 2
Ball - Balls: 2 Strikes: 2
Strike - Balls: 2 Strikes: 3
Strike out
Jackie throwing to T2 Batter 2 - Outs: 1
On First: false | On Second: false | On Third: false
Hit
Jackie throwing to T2 Batter 3 - Outs: 1
On First: true | On Second: false | On Third: false
Strike - Balls: 0 Strikes: 1
Strike - Balls: 0 Strikes: 2
Strike - Balls: 0 Strikes: 3
Strike out
Jackie throwing to T2 Batter 4 - Outs: 2
On First: true | On Second: false | On Third: false
Strike - Balls: 0 Strikes: 1
Ball - Balls: 1 Strikes: 1
Strike - Balls: 1 Strikes: 2
Strike - Balls: 1 Strikes: 3
Strike out
Bottom of Inning 1 Home: 0 Away: 0
Rodriguez throwing to T1 Batter 1 - Outs: 0
On First: false | On Second: false | On Third: false
Ball - Balls: 1 Strikes: 0
Strike - Balls: 1 Strikes: 1
Strike - Balls: 1 Strikes: 2
Strike - Balls: 1 Strikes: 3
Strike out
Rodriguez throwing to T1 Batter 5 - Outs: 1
On First: false | On Second: false | On Third: false
Hit
Rodriguez throwing to T1 Batter 5 - Outs: 1
On First: true | On Second: false | On Third: false
Ball - Balls: 1 Strikes: 0
Ball - Balls: 2 Strikes: 0
Ball - Balls: 3 Strikes: 0
Strike - Balls: 3 Strikes: 1
Strike - Balls: 3 Strikes: 2
Ball - Balls: 4 Strikes: 2
walk
Rodriguez throwing to T1 Batter 5 - Outs: 1
On First: true | On Second: true | On Third: false
Strike - Balls: 0 Strikes: 1
Ball - Balls: 1 Strikes: 1
Strike - Balls: 1 Strikes: 2
Strike - Balls: 1 Strikes: 3
Strike out
Rodriguez throwing to T1 Batter 5 - Outs: 2
On First: true | On Second: true | On Third: false
Strike - Balls: 0 Strikes: 1
Strike - Balls: 0 Strikes: 2
Hit
Rodriguez throwing to T1 Batter 5 - Outs: 2
On First: true | On Second: true | On Third: true
Strike - Balls: 0 Strikes: 1
Ball - Balls: 1 Strikes: 1
Ball - Balls: 2 Strikes: 1
Ball - Balls: 3 Strikes: 1
Ball - Balls: 4 Strikes: 1
walk
Rodriguez throwing to T1 Batter 5 - Outs: 2
On First: true | On Second: true | On Third: true
Ball - Balls: 1 Strikes: 0
Strike - Balls: 1 Strikes: 1
Strike - Balls: 1 Strikes: 2
Ball - Balls: 2 Strikes: 2
Strike - Balls: 2 Strikes: 3
Strike out Top of Inning 2 Home: 1 Away: 0
Jackie throwing to T2 Batter 5 - Outs: 0
On First: false | On Second: false | On Third: false
Ball - Balls: 1 Strikes: 0
Ball - Balls: 2 Strikes: 0
Ball - Balls: 3 Strikes: 0
Strike - Balls: 3 Strikes: 1
Hit
Jackie throwing to T2 Batter 6 - Outs: 0
On First: true | On Second: false | On Third: false
Strike - Balls: 0 Strikes: 1
Hit
Tyler Highlander throwing to T2 Batter 7 - Outs: 0
On First: true | On Second: true | On Third: false
Strike - Balls: 0 Strikes: 1
Ball - Balls: 1 Strikes: 1
Hit
Jackie throwing to T2 Batter 8 - Outs: 0
On First: true | On Second: true | On Third: true
Ball - Balls: 1 Strikes: 0
Ball - Balls: 2 Strikes: 0
Strike - Balls: 2 Strikes: 1
Strike - Balls: 2 Strikes: 2
Strike - Balls: 2 Strikes: 3
Strike out
Jackie throwing to T2 Batter 9 - Outs: 1
On First: true | On Second: true | On Third: true
Strike - Balls: 0 Strikes: 1
Strike - Balls: 0 Strikes: 2
Strike - Balls: 0 Strikes: 3
Strike out
Jackie throwing to T2 Batter 1 - Outs: 2
On First: true | On Second: true | On Third: true
Ball - Balls: 1 Strikes: 0
Ball - Balls: 2 Strikes: 0
Ball - Balls: 3 Strikes: 0
Hit
Runner Scores - Home: 1 Away: 1
Jackie throwing to T2 Batter 2 - Outs: 2
On First: true | On Second: true | On Third: true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started