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

the printTeam method: Creates a string with the name of the team followed by the

ID: 3545334 • Letter: T

Question

the printTeam method:
Creates a string with the name of the team followed by the first and last name and position of each of the players on the team

It says that fName cannot be resolved to a variable. Why is that?

Also how would i also get the position?

Help appreciated!

my code is:

import java.util.*;
import javax.swing.*;

public class Team {

ArrayList<Player> players = new ArrayList<Player>();

private static int numCenters;
private static int numForwards;
private static int numGuards;
private static int numPlayers;

private String teamName;


public Team(){

numCenters = 0;
numForwards = 0;
numGuards = 0;
numPlayers = 0;

}

public Team(String tm){

tm = teamName;

}

public static int getNumPlayers() {
return numPlayers;
}

public String addPlayer(String fName, String lName, String pos){

fName = "";
lName = "";
pos = "";

if (numForwards > 2){

JOptionPane.showMessageDialog(null, "There are two forwards on this team Player not added");

}
if(numGuards > 2){

JOptionPane.showMessageDialog(null, "There are already two guards on this team Player not added");

}
if(numCenters > 1){

JOptionPane.showMessageDialog(null, "There is already one center on this team Player not added");
}
else

return null;

return null;

}


public String printTeam(){

String prinT = teamName;
prinT += fName + lName + "Position:" +


}

}

An example of what the printMethod will do in the program

Returns:
string Example:
PigeonHawks

John Smith Position: forward

Bob Jones Position: center

Explanation / Answer

Following is the declaration for java.io.PrintStream.print() method

public PrintStream printf(Locale l,String format,Object... args)