Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(Program in SCALA and please use a main method to call the functions) Question: In a package named execution create a Scala class named Team
(Program in SCALA and please use a main method to call the functions)
Question: In a package named "execution" create a Scala class named "Team" and a Scala object named "Referee". Team will have: State values of type Int representing the strength of the team's offense and defense with a constructor to set these values. The parameters for the constructor should be offense then defense A third state variable named "score" of type Int that is not in the constructor, is declared as a var, and is initialized to O Referee will have: A method named "playGame" that takes two Team objects as parameters and return type Unit. This method will alter the state of each input Team by setting their scores equal to their offense minus the other Team's defense. If a Team's offense is less than the other Team's defense their score should be 0 (no negative scores) A method named "declareWinner" that takes two Teams as parameters and returns the Team with the higher score. If both Teams have the same score, return a new Team object with offense and defense both set to O Question: In a package named "execution" create a Scala class named "Team" and a Scala object named "Referee". Team will have: State values of type Int representing the strength of the team's offense and defense with a constructor to set these values. The parameters for the constructor should be offense then defense A third state variable named "score" of type Int that is not in the constructor, is declared as a var, and is initialized to O Referee will have: A method named "playGame" that takes two Team objects as parameters and return type Unit. This method will alter the state of each input Team by setting their scores equal to their offense minus the other Team's defense. If a Team's offense is less than the other Team's defense their score should be 0 (no negative scores) A method named "declareWinner" that takes two Teams as parameters and returns the Team with the higher score. If both Teams have the same score, return a new Team object with offense and defense both set to OStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started