资 源 简 介
`Imagine a team class, as shown
/
@version 1.0
**/
public class Team
{
private String name;
private int teamId;
public Team()
{
teamId=0;
name="";
}
public void setName(String name)
{
this.name=name;
}
public void setTeamId(int n)
{
this.teamId=n;
}
public int getTeamId()
{
return teamId;
}
public String getName()
{
return name;
}
}**
Also, a class Player exists independently (as of the following code:)
public class Player
{
private String fields;
private int id;
public Player()
{
fields="dirt track";
id=0;
}
public void setFields(String fields)
{
this.fields=fields;
}
public void setId(int n)
{
this.id=n;
}
public int getId()
{
return id;
}
public String getFields()
{
return fields;
}
}
Now, to speak about dependency, let us have a method in Team class as,
public void printDefaultPlayerDetails()
{
Player p=new Player();
System.out.println(p.getId());
System.out.println(p.getFields());
}
As we can see, the class Team cannot