Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to create a program that creates a MLB Baseball Franchise. I created the

ID: 3824975 • Letter: I

Question

I have to create a program that creates a MLB Baseball Franchise. I created the interface that I have to implement and the abstract class I have to extend. The abstract class will be the guideline for creating a baseball team in the MLB (Major League Baseball). The interface will be a template for creating a player for a baseball team. Lastly, I have to create a class that will implement the CreateGame interface. This class will simulate a game played between two teams. The simulation will run in a class called PlayBall. I have to do the following:

Implement the CreatePlayer Interface

Extend the Team Abstract Class

Implement the CreateGame Interface

Run the game

Show the current score while game is played after each inning.

Show the final score when the game ends.

Determine the winner and print the winner’s name and final score

create player interface below:

Create game interace below:

Create team abtract class

I just need help on getting started. I've had trouble for a while now. Any help will be very much appreciated, thanks in advance.

Explanation / Answer


public class BaseBallPlayer implements CreatePlayer {

   String name;
   String position;
   int age;
   boolean isout=false;
  
   @Override
   public void setPlayerName(String name) {
       // TODO Auto-generated method stub
       this.name=name;
   }

   @Override
   public String getPlayerName() {
       // TODO Auto-generated method stub
       return name;
   }

   @Override
   public void setPlayerPosition(String position) {
       // TODO Auto-generated method stub
       this.position=position;
   }

   @Override
   public String getPlayerPosition() {
       // TODO Auto-generated method stub
       return position;
   }

   @Override
   public void setPlayerAge(int age) {
       // TODO Auto-generated method stub
       this.age=age;
   }

   @Override
   public int getPlayerAge() {
       // TODO Auto-generated method stub
       return age;
   }

}

---------------------------

public class BaseBallTeam extends Team
{
  
   String name;
   String city;
BaseBallPlayer[] players=new BaseBallPlayer[this.rosterCount];
  
boolean Allout;
  
  
  
  
public void addPlayers(BaseBallPlayer[] players)
{

   this.players=players;

}
  
  
   @Override
   public void setTeamName(String name) {
       // TODO Auto-generated method stub
       this.name=name;
   }

   @Override
   public String getTeamName() {
       // TODO Auto-generated method stub
       return name;
   }

   @Override
   public void setTeamCity(String city) {
       // TODO Auto-generated method stub
       this.city=city;
   }

   @Override
   public String getTeamCity() {
       // TODO Auto-generated method stub
       return city;
   }
  
}

---------------------------------------

import java.util.Random;

public class BaseBallGame implements CreateGame{

   int innings;
   String winner;
  
   BaseBallTeam teamA;
   BaseBallTeam teamB;
  
   BaseBallTeam battingteam;
   BaseBallTeam ballingteam;
  
  
   Random random = new Random();
  
   BaseBallGame(BaseBallTeam a,BaseBallTeam b,int inn)
   {
       innings=inn;
       teamA=a;
       teamB=b;
   }
  
   @Override
   public void runGame() {
       // TODO Auto-generated method stub
      

       // syntax to generate number between min and max(min and max both are inclusive)
       //int randomNumber = random.nextInt(max + 1 - min) + min;
      
       int randomNumber = random.nextInt(1 + 1 - 0) + 0;
      
       if(randomNumber==1)
       {
       battingteam=teamA;
       }
       else
       {
           ballingteam=teamB;
       }
      
      
[213;.'1as for(int i=0;i<innings;i++)
       {
          
           while(!battingteam.Allout) //&& balls are left)
                   {
          
               //get each player out of batting team
           //here use random class to hit a home run or strike out etc.
           //then calculate the winner and put in winner instance variable
                   }
          
           System.out.println(printAfterInning());
       }
      
       System.out.println(printWinnerAfterGame());

   }

   @Override
   public String printAfterInning() {
       // TODO Auto-generated method stub
       return winner;
   }

   @Override
   public String printWinnerAfterGame() {
       // TODO Auto-generated method stub
       return winner;
   }

}