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

I have created the new class dLine and it has 4 players in it. The information f

ID: 3886342 • Letter: I

Question

I have created the new class dLine and it has 4 players in it. The information for these players is inside of a different class. I am having trouble searching for the numbers of the players so that I can return back all the information about the player. If you need more info then please let me know.

Creates 4 linemen (player objects that will be in the defensive line) Creates a defensiveLine object using these 4 players (see the description of the defensive line class below) Uses a method in defensiveLine to search for a player given by number and display the name, position, etc. of the player in the defensive line. The method has to deal with the case that the player is not found a part of code would like something like this o dl.search(50) // should find this player o dl.search(60) / test also with a player that will be "not found" o dl is the defensiveLine object, search is the method in defensiveLine that searches for player #50 and display its information don't ask for user input. Hard code the number to be searched. First, you have to design the new Java class called defensiveLine o A defensiveLine has 4 players, 2 with the position "defensive end" (DE) and with the position defensive tackle (DT) Create a method in defensiveLine.java 1. that searches for a player with a specific jersey number and displays the player information. If the player is not found displays a message saying so.

Explanation / Answer

public class Player {

int jerseryNo;

String name;

int position;

public int getJerseryNo() {

return jerseryNo;

}

public void setJerseryNo(int jerseryNo) {

this.jerseryNo = jerseryNo;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getPosition() {

return position;

}

public void setPosition(int position) {

this.position = position;

}

public Player(int jerseryNo, String name, int position) {

this.jerseryNo = jerseryNo;

this.name = name;

this.position = position;

}

@Override

public String toString() {

return "Player [jerseryNo=" + jerseryNo + ", name=" + name

+ ", position=" + position + "]";

}

}

============================================================================

import java.util.ArrayList;

import java.util.List;

public class DefensiveLine {

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

public static void main(String[] args) {

Player player=new Player(1,"koti",22);

Player player1=new Player(22,"koti",22);

Player player2=new Player(14,"koti",22);

Player player3=new Player(50,"koti",22);

players.add(player);

players.add(player1);

players.add(player2);

players.add(player3);

DefensiveLine d1=new DefensiveLine();

d1.search(50);

}

private void search(int i) {

for(int i1=0;i1<players.size();i1++)

{

Player playerinlist=players.get(i1);

if(i==playerinlist.getJerseryNo())

{

System.out.println("player found");

System.out.println(playerinlist);

}

}

}

}

output

player found
Player [jerseryNo=50, name=koti, position=22]