Answered step by step
Verified Expert Solution
Question
1 Approved Answer
answer in java programming language 8. Parts of Functions and Classes a. What is the purpose of the new in Record papers = new Record()?
answer in java programming language
8. Parts of Functions and Classes a. What is the purpose of the new in Record papers = new Record()? b. Why is the throw statement used in the method report? c. How many instances of the Game class are created when this program runs? d. In addGame, what would happen if you incremented us at the end of the method? e. Could print add one to the value of games as in r.games++? Why or why not? Il Game.java // Record.java IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII public class Record { private int wins; private int losses; private int ties; private int games; public class Game public static void main(String[] args) { Record papers = new Record(); Record scissors = new Record(); papers.addGame(4,3); scissors.addGame(0, 4); print("Papers", papers); print("Scissors", scissors); papers.addGame(5, 7); scissors.addGame(4, 6); scissors.addGame(9, 1); papers.addGame(3, 7); scissors.addGame(7,3); papers.addGame(0,5); papers.addGame(1, 4); scissors.addGame(3, 1); print("Papers", papers); print("Scissors", scissors); public Record() { wins = 0; losses = 0; ties = 0; games = 0; public void addGame (int us, int them) { if (us > them) { wins++; } else if (us 0) { return (wins * 100) / games; } else { throw new ArithmeticException ("divide by zero") Step 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