java program Following is a part of the source codes for NBATeam and NBA classes. Finish the programs for both classes to produce an output screen similar to the attached figure. Code: 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("Create the NBA team of Heats ...... "); NBAteam heat=new NBATeam("Heats"); System.out.println("Add a play to Heats? (yes/no): "); ifAddPlayer=input.next(); while(ifAddPlayer.equalsIgnoreCase("yes")){ System.out.println("What is the name to be added? "); playerName=input.next(); heat.addAPlayer(playerName); System.out.println("Add one more play to Heats? (yes/ no): "); ifAddPlayer=input.next(); } //construct Team spurs System.out.println("Create the NBA team of Spurs ...... "); NBAteam spur=new NBATeam("Spurs"); System.out.println("Add a play to Spurs? (yes/no): "); ifAddPlayer=input.next(); while(ifAddPlayer.equalsIgnoreCase("yes")){ System.out.println("What is the name to be added? "); playerName=input.next(); heat.addAPlayer(playerName); System.out.println("Add one more play to Spurs? (yes/ no): "); ifAddPlayer=input.next(); } /*simulate a series of at most 7 games by generating a random number; if the random number is bigger than 0.5, Heat wins; otherwise, Heat loses a game. As soon as a team wins 4 games, the series is over. */ System.out.println(heat); System.out.println(spurs); } } //NBATeam.java public class NBATeam { privateStringsTeamName; privateintnWin; privateintnLoss; privateString[]playerArray; }
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("Create the NBA team of Heats ...... ");
NBAteam heat=new NBATeam("Heats");
System.out.println("Add a play to Heats? (yes/no): ");
ifAddPlayer=input.next();
while(ifAddPlayer.equalsIgnoreCase("yes")){
System.out.println("What is the name to be added? ");
playerName=input.next();
heat.addAPlayer(playerName);
System.out.println("Add one more play to Heats? (yes/ no): ");
ifAddPlayer=input.next();
}
//construct Team spurs
System.out.println("Create the NBA team of Spurs ...... ");
NBAteam spur=new NBATeam("Spurs");
System.out.println("Add a play to Spurs? (yes/no): ");
ifAddPlayer=input.next();
while(ifAddPlayer.equalsIgnoreCase("yes")){
System.out.println("What is the name to be added? ");
playerName=input.next();
heat.addAPlayer(playerName);
System.out.println("Add one more play to Spurs? (yes/ no): ");
ifAddPlayer=input.next();
}
}
}
//NBATeam.java
public class NBATeam {
privateStringsTeamName;
privateintnWin;
privateintnLoss;
privateString[]playerArray;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images