Answered step by step
Verified Expert Solution
Question
1 Approved Answer
anyone help me with this homework please fffpublic String endGameEJ Compares the two player scores and returns the player tvho has the higher score: otherwise
anyone help me with this homework please
\f\f\fpublic String endGameEJ Compares the two player scores and returns the player tvho has the higher score: otherwise returns the String "tie". public void howliint pine} Simulates rolling a botvling ball that knocks dotvn the given number of pins. Lt'the number given is greater than the number ofpins still standing in this game. or ifthe game is already over. this method does nothing. Otherwise, this rnediod should correctly update the ame number: roll number: score: and status (DYE: or not}. Remember that the score should be updated for the current player. public void foultboolean iaFoul} Ifthe player steps over the foul line {i.e.= the iaFoul variable is true}: any pins knocked down for that roll vvill not count totvards the score. The roll is updated as usual. If the foul is in the rst roll, the pins dropped are reset and the next ball is thrown as usual. Lfthe foul is in the second ball. the turn is over. and the score remains at tvhat it tvas after the first roll. The spare or strike from previous round-[s3 is still in effect. [fthe game is over. this method does nothing. Remember that the score should be updated for the current player. public static final int FINE = in: :'L nominee\" representing the total number of pins. You may make any instance variables you need. But altvays remember that any variables that you need only in one method: must be declared as a local variable. Remember that your instance variables should always be declared private. and if you tvant to add any additional \"helper\" methods that are not specified, they must be declared private as tvell. Where's the matn} u1etI1od?? There isn't one! Like most Java classes, tbis isn't a complete program and you can't "run" it by itself. It's just a single class: that is: the denition for a type of object that might be part ofa larger system. To try out your class: you can 1cvrite a test class with a main method like the examples belotv in the getting started section There is also a specchecker (see below) that tvill perform a lot of functional tests. but vvhen you are developing and debugging your code at first you'll altvays tvant to have some simple test cases of your o1vn_ as in the getting started section belotv. \f\fhelper methods come in handy. Try to 1write some tests and see ifyou get the correct scores. 11. Next worlc on. the second player. 'Write the change DJ. aye:- {1 method to set the current player to player 2 and reset gameplay {except the score]. Modify the scoring part in how]. u and foul :} to update the score ofthe current player instead of just for player 1. game .changePlayer {1| .' game .bowl. {3} : game.bowl ['33: game.bowl H}! ; game .bowl [2} ; Syutem. 01: I: .println {game . getEoore (\"Player 2 "H ; If expected 2!] 12. Lastly: write due endGeune :1 method. This method compares the two player's scores and returns the player name who has the higher score. Ifhods players have the same score: returns the String \"tie". Remember that Strings are case-sensitive, so if you don"t write the exact String \"tie", the speccheclcer will not recognize it as a correct answer. Also: using conditionals is optional for this you can use the flu-lath class for comparison instead. System. out .prjmtln {game . endGeme {j l ; ffezpeoted \"Player 2" At some point= download the E'rpeci'Checlter= import it into your project as you did in lab 1 and run it. Always start reading error- mesaagesum the top. Ifyou base a missing or extra public method= if the method names or declarations are incorrect= or if something is really wrong like the class having the incorrect name or package= any such errors will appear rst in the output and will usually say \"Class does not conform to specication." Always x these rstStep 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