Answered step by step
Verified Expert Solution
Link Copied!

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
image text in transcribed
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions