Question
Following is a part of the source codes for NBATeam and NBA classes. Finish the java programs for both classes to produce an output screen
Following is a part of the source codes for NBATeam and NBA classes. Finish the java programs for both classes to produce an output screen similar to the following figure.
//File NBA.java
import java.util.Scanner;
public class NBA {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
String ifAddPlayer;
String playerName;
//construct Team Heat
System.out.println("Creat the NBA team of Heats ...... ");
NBATeam heat= new NBATeam("Heats");
System.out.print("Add a play to Heats? (yeso): ");
ifAddPlayer= input.next();
while (ifAddPlayer.equalsIgnoreCase("yes")){
System.out.print("What is the name to be added? ");
playerName=input.next();
heat.addAPlayer(playerName);
System.out.print("Add one more play to Heats? (yeso): ");
ifAddPlayer= input.next();
}
//construct Team spurs
//Your code here
/*simulate a series of atmost 7 games by generating a random number; if the random number is bigger than 0.5, Heat wins; otherwise Heat losses a game. As soon as team wins 4 games, the series is over. */
//Your code here
System.out.println(heat);
System.out.println(spurs);
}
}
//File NBATeam.java
public class NBATeam {
private String sTeamName;
private int nWin;
private int nLoss;
private String [] playerArray;
//Your code here
}//end of class definition
Creat the NBA team of Heats __. . .. Add a play to Heats? (yeso): yes What is the name to be added? James Add one more play to Heats? (yeso): yes What is the name to be added? Wade Add one more play to Heats? (yeso): no Creat the NBA team of Spurs . Add a play to Spurs? (yeso): yes What is the name to be added? Duncan Add one more play to Spurs? (yeso): ye What is the name to be added? Parker Add one more play to Spurs? (yeso): no Game on Now . Spurs ***WIN the series*** Heats[ James Wade ] win #: 2 10s : 4 Spurs[ Duncan Parker ] win #: 4 los : 2
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