1. Consider the class BasketballTeam above. What is the output of the following
ID: 3753300 • Letter: 1
Question
1. Consider the class BasketballTeam above. What is the output of the following demo driver program? BOX IN YOUR ANSWERpublic class BigGame { public static void main(String[ ] args) { BasketballTeam team1 = new BasketballTeam("Raiders"); BasketballTeam team2 = new BasketballTeam("Tigers"); team1.makeShot( ); team2.freeThrow( ); team1.threePoint( ); System.out.println ("Team 1 has " + team1.freeThrow( ) + " points."); team2.makeShot( ); System.out.print(team1); System.out.print(team2); } } 2. Using the BasketballTeam class above, write a complete demo driver class on the next page, which simulates a basketball game in the following way: instantiate two teams as above, and then assume the teams alternate possession of the ball for 20 times each. During each possession (show each possession of the ball with an if-else chain), the team with the ball has the following probabilities: • 35% chance of making a 2-point shot • 15% chance of making a 3-point shot • 20% chance of making a free throw • 30% chance of turning over the ball without scoring Use a double variable set to equal Math.random( ), together with some if-else statements, to control the probabilities. After each possession, print the score of both teams to the screen.
11:20 CSC 162 class and objects Basket...r Given the class below public class BasketballTeam private int score private String name; public BasketballTeam(String s) score 0, name s; public int getScore) return score; public String getName) return name public String toString return ("The +name+have" +score+ points.n"); publie int freeThrow) scoret returm score public int threePointO score +3; retum score, public int makeShot) score 2; return score - Calendar To Do Inbox
Explanation / Answer
1.output
----------------------
Team 1 has 6 points.
The Raidershave6points.
The Tigershave3points.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.