Basketball – Arrays

Create the following classes:

 

  1. Player Class
    1. Fields
      1. name – String – name of player
      2. attempted – int – number of field goals attempted
      3. made – int – number of field goals made
    2. Constructor
      1. There are two constructors
        1. Three parameters – name, attempted and made. If the number attempted is less than the number made, switch the two.
        2. One parameter – name. Set the field goals attempted and made to zero.
    3. Methods
      1. setMade – one parameter – it can not be more than the number attempted (error message if wrong)
      2. setAttempted – one parameter – it can not be less than the number made (error message if wrong)
      3. getMade – returns the number of field goals made
      4. getAttempted – returns the number of field goals attempted
      5. getName – returns the player name
      6. getPercentage – returns the field goal percentage (FGP) of the player – returns 0 if no field goals were attempted. (For example if the player attempted 12 and made 7, their field goal percentage would be 58.333333333 percent).
      7. effectiveness
        1. Returns a string showing the players effectiveness.
        2. A player is considered to be excellent if his/her FGP is 90% or over.  A player is good if his/her FGP is over 79%, OK if his/her FGP is over 70% and poor if his/her FGP is anything lower. Returns NA if a player has no attempts.
      8. printData
        1. Print out the name, made, attempted, percentage and effectiveness of the player.
        2. Each item should be on a separate line and have an appropriate prompt.
        3. Print a line after all the information is printed.

           

  2. A Class with a main method
    1. Create an array called team that can store information on 10 players. This must NOT be an ArrayList.
    2. Add the following players to the team:
      1. Jill, 9, 10
      2. Sallie, 0, 3
      3. Mary, 4, 7
      4. Sue, 5, 7
      5. Ali, 0, 0
      6. Sam, 11, 8
      7. Maria, 3, 4
      8. Chris, 9, 5
      9. Pam 2, 2
      10. Marge, 2, 4
    3. Use the methods of the Player class to do the following:
      1. Change the field goals made for Sam to 7.
      2. Change the field goals attempted for Maria to 10.
      3. Change the field goals attempted for Chris to 11.
    4. Use printData to print Sallie’s information
    5. Use printData to print Mary’s information
    6. Calculate and print out the total points scored by the team.
      1. Assume each field goal made is worth two points.
      2. You must use a for loop
    7. Print out the name of the player with the highest score, along with the player’s score.
    8. Poor Shooter
        1. Print out the name of the shooter with the lowest field goal percentage. Only include players who have attempted at least one field goal.
    9. Print Team
        1. In a neat table print out one line of information for each player who has attempted a field goal. The line includes the name, made, attempted, percentage and effectiveness of the player.
        2. At the end, print out the total field goals made and the average per player.
        3. Print a line before and after this part (create the line using be a lot of _ or = characters)

           

          Your program should work correctly even if player information is changed

           

Latest Assignments