Question: Question 1: [20 marks] Implement a class that will represent a football team in a package called football. We want to be ableto access the
Question 1: [20 marks]
- Implement a class that will represent a football team in a package called football. We want to be ableto access the class FootballTeam from any package.
- Add fields for the following properties, which cannot be accessed outside of the class.
- name of the team number of wins number of losses
- Write a constructor that accepts the name of the team, the number of wins, and the number of losses as arguments and sets the class properties to those values. This constructor should be accessible from any package.
- Write a second constructor that takes only the name of the team as an argument. This constructor should set the name of the team to the argument and the set the number of wins and losses to 0. (Hint: The body of this constructor should be one line and it should call the first constructor.) Thisconstructor should be accessible from any package.
- Write methods that return the name of the team, the number of the wins, and the number of losses.These methods should be accessible from any package.
- Next write a method to increase the numbers of wins by 1 and another method to increase thenumber of losses by one. These methods should only be accessible from inside the football package.
- Write a method that returns true when a team has a good record, meaning the team has more winsthan losses. This method should be accessible from any package.
- Finally, add a main method to the FootballTeam class. In the main method, construct a FootballTeam named "AITI" with 3 wins and 5 losses. Call the method that returns true when the team has a good record and print out the result. Now make three calls to the method that increases the number of wins by 1. Lastly, call the "good record" method again and print out the result.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
