Вы находитесь на странице: 1из 2

Applied Data Structures – Lab Test

Finding Basket Ball Players

The UoM basketball team needs 3 additional players to complete its squad to play in the InterCollegiate
Basketball tournament. Since the deadline is quite short, the coach does not have time to audition all
potential players. However, over the past years, it has been seen that taller players do better. The next
criteria for the performance of players is their bodymass index (BMI), with a higher BMI being
preferred.

You are to write a program to select the three best players to join the squad. Your program should
prompt for the number of players, then, ask for details of each player and add them to a LinkedList.
The program should then print the details of the three players who will join the squad. The players are
prefered in terms of height, then BMI, then according to descending order of name)

You are provided with the BasketPlayer.java, as follows

public class BasketPlayer {

private String name;


private float height;
private float bmi;

public BasketPlayer(String name, float height, float bmi) {


super();
this.name = name;
this.height = height;
this.bmi = bmi;
}//end BasketPlayer

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}

public float getHeight() {


return height;
}

public void setHeight(float height) {


this.height = height;
}

public float getBmi() {


return bmi;
}

public void setBmi(float bmi) {


this.bmi = bmi;
}
@Override
public String toString() {
return "BasketPlayer [bmi=" + bmi + ", height=" + height + ",
name="
+ name + "]";
}
}//end class

Write the file ManageBasketPlayers.java. Submit your work as a zip file with both
ManageBasketPlayers.java and BasketPlayer.java. Otherwise, include BasketPlayer.java as a static
class within ManageBasketPlayers.java and submit ManageBasketPlayers.java.

A sample run with behavior of the system is as follows (user input underlined):

Enter Number of players


5
Enter name of player 1
Anwar
Enter height of player 1 (m)
3
Enter Body Mass Index (BMI) of player 1
2
Enter name of player 2
Michel Jordan
Enter height of player 2 (m)
1
Enter Body Mass Index (BMI) of player 2
2
Enter name of player 3
Spider Man
Enter height of player 3 (m)
3
Enter Body Mass Index (BMI) of player 3
4
Enter name of player 4
IronMan
Enter height of player 4 (m)
3
Enter Body Mass Index (BMI) of player 4
5
Enter name of player 5
SuperMan
Enter height of player 5 (m)
3
Enter Body Mass Index (BMI) of player 5
4
The three missing players for the team:
BasketPlayer [bmi=5.0, height=3.0, name=IronMan]
BasketPlayer [bmi=4.0, height=3.0, name=SuperMan]
BasketPlayer [bmi=4.0, height=3.0, name=Spider Man]

Вам также может понравиться