PROGRAM INSTRUCTIONS: Code a program that tracks the wins-losses of the athletic teams at your school. Create 3 separate class files in a project folder; declare variables at the class level; create and use a one-dimensional (1D) array typed as the Team class so it can contain team objects; use the for loop to populate the array and extract data from the array; and code multiple methods.

1. Download the Creating Projects in DrJava PDF (instructors version) on how to create a project folder that manages multiple .java files stored in the same folder. The project folder has the same name as the group .java file. You are creating 3 separate .java files to be stored in the project folder:

  • GroupMembersLastNamesSectionNoPANo.java contains only the main(),
  • TeamStats.java, and
  • Team.java.

2. The main() will instantiate (create) an object of the TeamStats class and use that object to call start(). Make sure you exit main().

3. The TeamStats class will have 4 methods: an empty constructor, start(), processWinsLosses(), and displayTeamsStats(). There are NO value-returning and/or value-receiving methods in the TeamStats class. You will create a 1D array called myTeams at the class level as a null array. The type for this array will be Team.

  • In start(),
    • if the answer is "Y" to tracking the performance of your teams then processWinsLosses() and displayTeamsStats() are called;
    • otherwise the program exits with this message: Thank you! Exiting program.
  • In processWinsLosses(), the user is prompted for the number of teams to be tracked by the program. That number will be used to give size to the myTeams array.
  • In displayTeamsStats(), the output is printed according to specs (see sample output).
  • Your output will have uppercase and lowercase for the same word in different parts of the print out. You'll need two (2) methods from the String class: toLowerCase() and toUpperCase(). Use the String variable to call these methods. Example: school.toUpperCase() where school is the String variable that stores the school's name.

4. The Team class will have the set methods to capture the team information and the get methods to return the captured data

  • Code an empty constructor.
  • Code an overloaded constructor that accepts the data for the team and its coach. Assign the parameter variables to global variables with the same name.
  • Code a method called setTeam() that prompts for each team type.
  • Code a method called setCoach() that prompts for the teams coach.
  • Code a method called setTotalGames() that prompts for the total number games played by the team.
  • Code a method called setWins() that prompts for the teams number of wins.
  • Code get methods for each global variable that has a set method. These get methods only return the global variables.

5. Code at the class level only those variables that need to be used by more than one method.

6. Develop your code by planning the logic first. You will only pseudocode the plan for the Team class. The plan is worth 10% of your grade. Save your plan as GroupMembersLastNamesSecNoPA4Plan. Download the plan instructions and the plan template through the links posted for this assignment on Blackboard. There is an example of a PA4 plan on Blackboard. Use that to assist with your plan.

  • The prompts will tell you what input variables you will need.
  • The output will tell you the type of calculations you will need (if any) and whether you will need to declare additional variables.
  • The output will tell you the order of logic for your code.

7. Please work in groups of only two from the same section. The group will only submit one plan and one project with all the files. This means only one of the group members can submit the PA. I will ignore all submissions if both group members post submissions. The project folder and the main() file will reflect the last names of both group members. E.g., CosbyHuxtable001PA4. Through line and method comments, group members will claim authorship and the work has to be evenly distributed. Example:

int age = 0; //By Bill Cosby: STORES AN AGE

/**
*By Cliff Huxtable
*main() captures a first and last name, an age, and a zip code.
*It multiplies the age and zip code to get a product.
*Output will be made to the console screen and to a
*GUI window.
*/

WARNING: One group member CANNOT and MUST NOT carry the load for these assignments. All group members have to be actively engaged in developing and writing code to do well on the exams and in Java II.

8. Program Documentation: In your program, YOU MUST insert a program purpose in the first comment box. The content of that first comment box was shown to you in the Anatomy of a Java Program lecture for chapter 1. Use Javadoc comment boxes beginning with /** and ending with */. Insert a Javadoc comment box above each of the methods in each of the programs explaining what is going on. Line comment the import statements and the variables.

PROMPTS: Code the bold from the prompts below in the printf statements that capture data into your program. Once again, the prompts tell you your input variables. Keep in mind that these prompts are not all in the same class.

1st Prompt: Code in start(). The method start() will be the only method from the TeamStats class called by the main()

Do you want to track the performance of the athletic teams at your school? Enter 'Y' or 'N':

If the answer to the above question is "N" display the following message:

Thank you! Exiting program.

If the answer is "Y" then proceed to prompts 2 through 7.

2nd Prompt: Code in processWinsLosses().

What is the name of your school?

3rd Prompt: Code in processWinsLosses(). The value captured here is the size of the array called myTeams.

How many athletic teams do you have at your school?

4th Prompt: Code in setTeam().

Enter the team type:

5th Prompt: Code in setCoach().

Enter the name of the coach:

6th Prompt: Code in setTotalGames(). The Xs represent the type of the team (basketball, football, etc.). Note the team type is all lowercase.

Enter the total number of games played for the xxxxxxxxxxxx team:

7th Prompt: Code in setWins(). The Xs represent the type of the team.

Enter the number of wins for the xxxxxxxxxxxx team:

FINAL OUTPUT SPECIFICATIONS: The output will print the header, the team's name, the coach, the total number of games played, the number of wins, the number of losses and the win percent as a decimal. There are multiple teams which is why the output specs are repeated. The number of losses is calculated. The header should be triple-line advanced from the last prompt or output. The printing of the output will be in a method called displayTeamsStats() from the TeamStats class. The Xs in the header is the school name.

TEAMS WIN-LOSS RECORD FOR XXXXXXXXXXXX

Team: Xxxxxxxxxxxx
Coach: Xxxxxxxxxxxx
Total Games: ZZ9
No. of Wins: ZZ9
No. of Losses: ZZ9
Win Percent: Z9.99%

Team: Xxxxxxxxxxxx
Coach: Xxxxxxxxxxxx
Total Games: ZZ9
No. of Wins: ZZ9
No. of Losses: ZZ9
Win Percent: Z9.99%

***END OF OUTPUT SPECIFICATIONS***
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.