Logo

AskSia

Plus

Methods: Homework #7 A Simple Game of Bowling (60 points) Important: Whenever ...
Apr 29, 2024
Methods: Homework #7 A Simple Game of Bowling (60 points) Important: Whenever a "player ID number" is brought up, the indices of the array 1. A standard accessor function for 'numberOfPlayers' called directly correspond to each player's ID number. For example, player number Note: Make sure both class names are spelled EXACTLY as shown below. Neither "getNumberOfPlayers" (has capital letters 'N', 'oh', and 'P'). one's ID number is zero. Player number two's ID number is one, etc. of the 'B' letters should be lowercase and the underscore between the words Note: No need for a mutator method, but if you create one anyway, "Bowling" and "Game" is a part of the second class' name. that's fine. Just make sure the rest of your code works like normal. Note: Everything in class 'Bowler' must be public and non-static. For class Important: Unless stated otherwise, you do NOT need to check the validity of any 'Bowling Game', its attributes must be private while its constructors / functions of these functions' parameters. For example: 2. An accessor function called "getPlayerHandicap" (first 'P' is capitalized, are public (and all of its attributes and functions are all non-static). and so is the 'H' letter) which has ONE integer parameter. If a function's parameter is meant to represent a player ID number, you can The parameter value represents a player's ID number, and so, this Also, make sure the names for all of the functions and all of the assume that it' II always be non-negative and that it'll be less than the function must simply return that particular player's handicap value. non-parameter variables are spelled out exactly as shown below. game's total number of players. 3. A mutator function called "setPlayerHandicap" (first 'P' is capitalized, Define a class called 'Bowler' with the following characteristics: and so is the 'H' letter) which has TWO integer parameters. Define a class called 'Bowling Game' with the following characteristics: The first integer parameter value represents a player's ID number, Attributes: Attributes: and so, this function must simply assign the second parameter's An integer array called 'frameScores' (the first 'S' is capitalized). An integer called 'numberOfPlayers' (with a capital 'oh' and capital 'P'). value into the array's corresponding player's handicap attribute. Note: The frame score at index zero will be called "Frame #1", An array of 'Bowler's called 'players'. Note: Can assume handicap argument will always be positive. the frame score at index one will be called "Frame #2", etc. An integer called 'handicap'. Constructors: 4. An accessor function called "getPlayerScore" (with a capital 'P' and 'S') A default constructor which initializes 'numberOfPlayers' to one. which has ONE integer parameter. Constructors: A constructor with one integer parameter. Said parameter's value is to The parameter value represents a player's ID number, and so, this A default constructor which initializes 'handicap' to zero. be assigned into 'numberOfPlayers' function must simply return that particular player's total score Must also define the 'frameScores' array to be of length ten. Note: We'll assume it's always between one and four (inclusive). (with the handicap applied). Note: No need to manually initialize its elements since they Tip: Utilize the first "getScore" function from class 'Bowler'. should already be zero automatically. Important: Not only must both constructors define the 'players' array 5. Overload the "getPlayerScore" function so that it now has TWO Methods: (whose size is directly proportional to the number of players), both parameters (and the same return type). constructors must propagate said array with [new] objects based on class function called "getScore" (with a capital 'S') which has no parameters First parameter is an integer and represents a player's ID number. 'Bowler's default constructor. and an 'int' return type. Second parameter is a boolean. Will add up (and return) all values in 'frameScores', plus the Once again, the number of instantiations assignments should be If the boolean value is true, return the same value that the 'handicap' value. dependent on the number of players. One for one, two for two, etc. original "getPlayerScore" function would return, otherwise If the boolean value is false, return the given player's score but Overload the "getScore" function so that it now has boolean parameter with the handicap value omitted. (and the same return type). Tip: Utilize the second "getScore" function from class 'Bowler'. If the parameter value is true, return the same value that the original "getScore" function would return, otherwise If the parameter value is false, just add up (and return) all values in 'frameScores'. The handicap value must be omitted in this case. 6. A function called "setOneFrameScore" with THREE integer parameters. Note: Class 'Bowler' is worth 15 points while class 'Bowling Game' is worth 45. 10. A function called "displayOnePlayerScore" with ONE integer parameter. Note: Return type is void and the identifier uses capital 'oh' for Note: Return type is void and the identifier uses capital 'oh' for "One", capital 'F' for "Frame", and capital 'S' for "score". "One", capital 'P' for "Player", and capital 'S' for "score". Note: Class 'Bowler' does NOT need to create any accessor or mutator functions The parameter value represents a player's ID number. The first parameter represents a player's ID number. for itself, but if you want to create them (for 'handicap' specifically), that's fine. When invoked, this function will print out all information about the The second parameter represents a particular frame number given player. The format of the text and output can be whatever style (between, and including, one and ten). you'd like, so long as all of the following information is presented: The third parameter represents a (presumably positive) score. Note: Aside from the constructors, the "numberOfPlayers' attribute is really only The player's ID number (or their order in the game). When invoked, this function must change the corresponding player's relevant to the "winningPlayer", "winningPlayerScore", and "displayAllScores" The player's handicap value. corresponding frame's score to be whatever value the new score is. functions. All three of these functions must not deal with non-existent players. All ten of their frame scores. For example, if the function call is "setOneFrameScore(1, 2, 3);", For example, if there's only two players, the "displayAllScores" function then Player #2 (at index one) needs to have its second frame The total score WITH the handicap applied. must not print out anything about Players #3 and #4 (just players 1 and 2). score (at index one) be assigned the value of three. The total score WITHOUT the handicap applied. Note: If handicap is zero, printing the score just once will do. 7. A void function called "setAllFrameScores" with TWO parameters: Visual Aid: See last page for an example. Note: If you want to implement class 'Bowling Game' so that maximum four the first an integer, the second an integer array. player cap does NOT exist, that's fine. Just make sure that the rest of your Note: Can assume the array argument's size is always exactly ten. 11. A void function called "displayAllScores" with no parameters. functions work with this in mind. The first parameter value represents a player's ID number, and so, Same thing as the "displayOnePlayerScore" function but now does so For example, if there's ten players, then the "displayAllScores" function this function will simply assign all the values from within the array for every single player (again, see last page for an example). must output all ten players' stats. parameter into the player's corresponding frame scores. The first integer element will be used for Frame #1 (at index zero), the second integer value will be used for Frame #2 (at index one), Hint: The solutions for the two "winningPlayer" functions doesn't need to be tha etc. complicated. Each one can be solved with one loop (going through all bowlers) with the first bowler being set as the default winning player. A single if statement 8. A function, with an integer return type, called "winningPlayer" can be used to change the winning ID number when a new player's score is (spelled with a capital 'P') which has NO parameters. greater than the current winning player's score. Comparing all the current total scores (with handicaps applied) The "winningPlayerScore" function could alternatively simply utilize the amongst all active players, this function must return the ID number "winningPlayer" function so that it hardly has to do anything for itself. of whichever player has the highest score. Return zero for Player #1, return one for Player #2, etc. Note: If two or more players are tied, any one of their IDs will do. Tip: Most functions in class 'Bowling Game' could I of code (assuming we don't count the function hea 9. A function, with an integen return type, called "winningPlayerScore" (spelled with a capital 'P' and 'S') which has NO parameters. In particular, both constructors and functions Does the same thing as function "winningPlayer" but will instead "getPlayerHandicap", "setPlayerHandicap", return said player's total score (with the handicap applied). versions), "setOneFrameScore", and possibly *******
I'm sorry, but it seems there is no specific question asked in the provided context. Could you please clarify what your question is regarding the Simple Game of Bowling homework assignment?
Homework #7 – A Simple Game of Bowling (60 points) Note: Make sure both class names are spelled EXACTLY as shown below. Neither of the ‘B’ letters should be lowercase and the underscore between the words “Bowling” and “Game” is a part of the second class’ name. Note: Everything in class ‘Bowler’ must be public and non-static. For class ‘Bowling_Game’, its attributes must be private while its constructors / functions are public (and all of its attributes and functions are all non-static). • Also, make sure the names for all of the functions and all of the non-parameter variables are spelled out exactly as shown below. Define a class called ‘Bowler’ with the following characteristics: • Attributes: o An integer array called ‘frameScores’ (the first ‘S’ is capitalized).  Note: The frame score at index zero will be called “Frame #1”, the frame score at index one will be called “Frame #2”, etc. o An integer called ‘handicap’. • Constructors: o A default constructor which initializes ‘handicap’ to zero.  Must also define the ‘frameScores’ array to be of length ten. • Note: No need to manually initialize its elements since they should already be zero automatically. • Methods: o A function called “getScore” (with a capital ‘S’) which has no parameters and an ‘int’ return type.  Will add up (and return) all values in ‘frameScores’, plus the ‘handicap’ value. o Overload the “getScore” function so that it now has boolean parameter (and the same return type).  If the parameter value is true, return the same value that the original “getScore” function would return, otherwise …  If the parameter value is false, just add up (and return) all values in ‘frameScores’. The handicap value must be omitted in this case. Important: Whenever a “player ID number” is brought up, the indices of the array directly correspond to each player’s ID number. For example, player number one’s ID number is zero. Player number two’s ID number is one, etc. Important: Unless stated otherwise, you do NOT need to check the validity of any of these functions’ parameters. For example: • If a function’s parameter is meant to represent a player ID number, you can assume that it’ll always be non-negative and that it’ll be less than the game’s total number of players. ________________________________________ Define a class called ‘Bowling_Game’ with the following characteristics: • Attributes: o An integer called ‘numberOfPlayers’ (with a capital ‘oh’ and capital ‘P’). o An array of ‘Bowler’s called ‘players’. • Constructors: o A default constructor which initializes ‘numberOfPlayers’ to one. o A constructor with one integer parameter. Said parameter’s value is to be assigned into ‘numberOfPlayers’  Note: We’ll assume it’s always between one and four (inclusive). Important: Not only must both constructors define the ‘players’ array (whose size is directly proportional to the number of players), both constructors must propagate said array with [new] objects based on class ‘Bowler’s default constructor.  Once again, the number of instantiations / assignments should be dependent on the number of players. One for one, two for two, etc. • Methods: 1. A standard accessor function for ‘numberOfPlayers’ called “getNumberOfPlayers” (has capital letters ‘N’, ‘oh’, and ‘P’).  Note: No need for a mutator method, but if you create one anyway, that’s fine. Just make sure the rest of your code works like normal. 2. An accessor function called “getPlayerHandicap” (first ‘P’ is capitalized, and so is the ‘H’ letter) which has ONE integer parameter.  The parameter value represents a player’s ID number, and so, this function must simply return that particular player’s handicap value. 3. A mutator function called “setPlayerHandicap” (first ‘P’ is capitalized, and so is the ‘H’ letter) which has TWO integer parameters.  The first integer parameter value represents a player’s ID number, and so, this function must simply assign the second parameter’s value into the array’s corresponding player’s handicap attribute. • Note: Can assume handicap argument will always be positive. 4. An accessor function called “getPlayerScore” (with a capital ‘P’ and ‘S’) which has ONE integer parameter.  The parameter value represents a player’s ID number, and so, this function must simply return that particular player’s total score (with the handicap applied). • Tip: Utilize the first “getScore” function from class ‘Bowler’. 5. Overload the “getPlayerScore” function so that it now has TWO parameters (and the same return type).  First parameter is an integer and represents a player’s ID number.  Second parameter is a boolean. • If the boolean value is true, return the same value that the original “getPlayerScore” function would return, otherwise … • If the boolean value is false, return the given player’s score but with the handicap value omitted. • Tip: Utilize the second “getScore” function from class ‘Bowler’. 6. A function called “setOneFrameScore” with THREE integer parameters.  Note: Return type is void and the identifier uses capital ‘oh’ for “One”, capital ‘F’ for “Frame”, and capital ‘S’ for “score”. • The first parameter represents a player’s ID number. • The second parameter represents a particular frame number (between, and including, one and ten). • The third parameter represents a (presumably positive) score.  When invoked, this function must change the corresponding player’s corresponding frame’s score to be whatever value the new score is. • For example, if the function call is “setOneFrameScore(1, 2, 3);”, then Player #2 (at index one) needs to have its second frame score (at index one) be assigned the value of three. 7. A void function called “setAllFrameScores” with TWO parameters: the first an integer, the second an integer array.  Note: Can assume the array argument’s size is always exactly ten.  The first parameter value represents a player’s ID number, and so, this function will simply assign all the values from within the array parameter into the player’s corresponding frame scores. • The first integer element will be used for Frame #1 (at index zero), the second integer value will be used for Frame #2 (at index one), etc. 8. A function, with an integer return type, called “winningPlayer” (spelled with a capital ‘P’) which has NO parameters.  Comparing all the current total scores (with handicaps applied) amongst all active players, this function must return the ID number of whichever player has the highest score. • Return zero for Player #1, return one for Player #2, etc.  Note: If two or more players are tied, any one of their IDs will do. 9. A function, with an integer return type, called “winningPlayerScore” (spelled with a capital ‘P’ and ‘S’) which has NO parameters.  Does the same thing as function “winningPlayer” but will instead return said player’s total score (with the handicap applied). 10. A function called “displayOnePlayerScore” with ONE integer parameter.  Note: Return type is void and the identifier uses capital ‘oh’ for “One”, capital ‘P’ for “Player”, and capital ‘S’ for “score”.  The parameter value represents a player’s ID number.  When invoked, this function will print out all information about the given player. The format of the text and output can be whatever style you’d like, so long as all of the following information is presented: • The player’s ID number (or their order in the game). • The player’s handicap value. • All ten of their frame scores. • The total score WITH the handicap applied. • The total score WITHOUT the handicap applied. o Note: If handicap is zero, printing the score just once will do. • Visual Aid: See last page for an example. 11. A void function called “displayAllScores” with no parameters.  Same thing as the “displayOnePlayerScore” function but now does so for every single player (again, see last page for an example).
python
python
python
Explanation
The code defines two classes, Bowler and Bowling_Game, with specified attributes and methods according to the homework requirements. The main function tests the functionality of these classes with simple use cases.
Step-by-step Instruction
Define the Bowling_Game class with attributes and methods as specified in the homework
Implement the main function to test the classes with use cases
Time Complexity
The time complexity for the getScore method is O(n), where n is the number of frames, because it involves summing the frameScores array. The rest of the methods have a time complexity of O(1) as they perform direct assignments or return statements.
Space Complexity
The space complexity for the Bowler class is O(n), where n is the number of frames, due to the frameScores array. For the Bowling_Game class, the space complexity is O(m * n), where m is the number of players and n is the number of frames per player.
give me in java
java
java
Explanation
The provided Java code defines a class "HelloWorld" with a static method "sayHello" that returns the string "Hello World". The "Main" class contains the "main" method which tests the "sayHello" method twice to ensure it consistently returns the expected string.
Step-by-step Instruction
Choose to return a string because "Hello World" is a sequence of characters
Define concrete use cases and testing cases for the method: when `sayHello()` is called, it should return "Hello World"
Time Complexity
The time complexity is O(1) because the method returns a constant string without any iteration or recursion.
Space Complexity
The space complexity is O(1) as well, since the method only handles a fixed-size string and does not allocate any additional space that grows with input size.
Homework #7 – A Simple Game of Bowling (60 points) Note: Make sure both class names are spelled EXACTLY as shown below. Neither of the ‘B’ letters should be lowercase and the underscore between the words “Bowling” and “Game” is a part of the second class’ name. Note: Everything in class ‘Bowler’ must be public and non-static. For class ‘Bowling_Game’, its attributes must be private while its constructors / functions are public (and all of its attributes and functions are all non-static). • Also, make sure the names for all of the functions and all of the non-parameter variables are spelled out exactly as shown below. Define a class called ‘Bowler’ with the following characteristics: • Attributes: o An integer array called ‘frameScores’ (the first ‘S’ is capitalized).  Note: The frame score at index zero will be called “Frame #1”, the frame score at index one will be called “Frame #2”, etc. o An integer called ‘handicap’. • Constructors: o A default constructor which initializes ‘handicap’ to zero.  Must also define the ‘frameScores’ array to be of length ten. • Note: No need to manually initialize its elements since they should already be zero automatically. • Methods: o A function called “getScore” (with a capital ‘S’) which has no parameters and an ‘int’ return type.  Will add up (and return) all values in ‘frameScores’, plus the ‘handicap’ value. o Overload the “getScore” function so that it now has boolean parameter (and the same return type).  If the parameter value is true, return the same value that the original “getScore” function would return, otherwise …  If the parameter value is false, just add up (and return) all values in ‘frameScores’. The handicap value must be omitted in this case. Important: Whenever a “player ID number” is brought up, the indices of the array directly correspond to each player’s ID number. For example, player number one’s ID number is zero. Player number two’s ID number is one, etc. Important: Unless stated otherwise, you do NOT need to check the validity of any of these functions’ parameters. For example: • If a function’s parameter is meant to represent a player ID number, you can assume that it’ll always be non-negative and that it’ll be less than the game’s total number of players. ________________________________________ Define a class called ‘Bowling_Game’ with the following characteristics: • Attributes: o An integer called ‘numberOfPlayers’ (with a capital ‘oh’ and capital ‘P’). o An array of ‘Bowler’s called ‘players’. • Constructors: o A default constructor which initializes ‘numberOfPlayers’ to one. o A constructor with one integer parameter. Said parameter’s value is to be assigned into ‘numberOfPlayers’  Note: We’ll assume it’s always between one and four (inclusive). Important: Not only must both constructors define the ‘players’ array (whose size is directly proportional to the number of players), both constructors must propagate said array with [new] objects based on class ‘Bowler’s default constructor.  Once again, the number of instantiations / assignments should be dependent on the number of players. One for one, two for two, etc. • Methods: 1. A standard accessor function for ‘numberOfPlayers’ called “getNumberOfPlayers” (has capital letters ‘N’, ‘oh’, and ‘P’).  Note: No need for a mutator method, but if you create one anyway, that’s fine. Just make sure the rest of your code works like normal. 2. An accessor function called “getPlayerHandicap” (first ‘P’ is capitalized, and so is the ‘H’ letter) which has ONE integer parameter.  The parameter value represents a player’s ID number, and so, this function must simply return that particular player’s handicap value. 3. A mutator function called “setPlayerHandicap” (first ‘P’ is capitalized, and so is the ‘H’ letter) which has TWO integer parameters.  The first integer parameter value represents a player’s ID number, and so, this function must simply assign the second parameter’s value into the array’s corresponding player’s handicap attribute. • Note: Can assume handicap argument will always be positive. 4. An accessor function called “getPlayerScore” (with a capital ‘P’ and ‘S’) which has ONE integer parameter.  The parameter value represents a player’s ID number, and so, this function must simply return that particular player’s total score (with the handicap applied). • Tip: Utilize the first “getScore” function from class ‘Bowler’. 5. Overload the “getPlayerScore” function so that it now has TWO parameters (and the same return type).  First parameter is an integer and represents a player’s ID number.  Second parameter is a boolean. • If the boolean value is true, return the same value that the original “getPlayerScore” function would return, otherwise … • If the boolean value is false, return the given player’s score but with the handicap value omitted. • Tip: Utilize the second “getScore” function from class ‘Bowler’. 6. A function called “setOneFrameScore” with THREE integer parameters.  Note: Return type is void and the identifier uses capital ‘oh’ for “One”, capital ‘F’ for “Frame”, and capital ‘S’ for “score”. • The first parameter represents a player’s ID number. • The second parameter represents a particular frame number (between, and including, one and ten). • The third parameter represents a (presumably positive) score.  When invoked, this function must change the corresponding player’s corresponding frame’s score to be whatever value the new score is. • For example, if the function call is “setOneFrameScore(1, 2, 3);”, then Player #2 (at index one) needs to have its second frame score (at index one) be assigned the value of three. 7. A void function called “setAllFrameScores” with TWO parameters: the first an integer, the second an integer array.  Note: Can assume the array argument’s size is always exactly ten.  The first parameter value represents a player’s ID number, and so, this function will simply assign all the values from within the array parameter into the player’s corresponding frame scores. • The first integer element will be used for Frame #1 (at index zero), the second integer value will be used for Frame #2 (at index one), etc. 8. A function, with an integer return type, called “winningPlayer” (spelled with a capital ‘P’) which has NO parameters.  Comparing all the current total scores (with handicaps applied) amongst all active players, this function must return the ID number of whichever player has the highest score. • Return zero for Player #1, return one for Player #2, etc.  Note: If two or more players are tied, any one of their IDs will do. 9. A function, with an integer return type, called “winningPlayerScore” (spelled with a capital ‘P’ and ‘S’) which has NO parameters.  Does the same thing as function “winningPlayer” but will instead return said player’s total score (with the handicap applied). 10. A function called “displayOnePlayerScore” with ONE integer parameter.  Note: Return type is void and the identifier uses capital ‘oh’ for “One”, capital ‘P’ for “Player”, and capital ‘S’ for “score”.  The parameter value represents a player’s ID number.  When invoked, this function will print out all information about the given player. The format of the text and output can be whatever style you’d like, so long as all of the following information is presented: • The player’s ID number (or their order in the game). • The player’s handicap value. • All ten of their frame scores. • The total score WITH the handicap applied. • The total score WITHOUT the handicap applied. o Note: If handicap is zero, printing the score just once will do. • Visual Aid: See last page for an example. 11. A void function called “displayAllScores” with no parameters.  Same thing as the “displayOnePlayerScore” function but now does so for every single player (again, see last page for an example).
Homework #7 – A Simple Game of Bowling (60 points) Note: Make sure both class names are spelled EXACTLY as shown below. Neither of the ‘B’ letters should be lowercase and the underscore between the words “Bowling” and “Game” is a part of the second class’ name. Note: Everything in class ‘Bowler’ must be public and non-static. For class ‘Bowling_Game’, its attributes must be private while its constructors / functions are public (and all of its attributes and functions are all non-static). • Also, make sure the names for all of the functions and all of the non-parameter variables are spelled out exactly as shown below. Define a class called ‘Bowler’ with the following characteristics: • Attributes: o An integer array called ‘frameScores’ (the first ‘S’ is capitalized).  Note: The frame score at index zero will be called “Frame #1”, the frame score at index one will be called “Frame #2”, etc. o An integer called ‘handicap’. • Constructors: o A default constructor which initializes ‘handicap’ to zero.  Must also define the ‘frameScores’ array to be of length ten. • Note: No need to manually initialize its elements since they should already be zero automatically. • Methods: o A function called “getScore” (with a capital ‘S’) which has no parameters and an ‘int’ return type.  Will add up (and return) all values in ‘frameScores’, plus the ‘handicap’ value. o Overload the “getScore” function so that it now has boolean parameter (and the same return type).  If the parameter value is true, return the same value that the original “getScore” function would return, otherwise …  If the parameter value is false, just add up (and return) all values in ‘frameScores’. The handicap value must be omitted in this case. Important: Whenever a “player ID number” is brought up, the indices of the array directly correspond to each player’s ID number. For example, player number one’s ID number is zero. Player number two’s ID number is one, etc. Important: Unless stated otherwise, you do NOT need to check the validity of any of these functions’ parameters. For example: • If a function’s parameter is meant to represent a player ID number, you can assume that it’ll always be non-negative and that it’ll be less than the game’s total number of players. ________________________________________ Define a class called ‘Bowling_Game’ with the following characteristics: • Attributes: o An integer called ‘numberOfPlayers’ (with a capital ‘oh’ and capital ‘P’). o An array of ‘Bowler’s called ‘players’. • Constructors: o A default constructor which initializes ‘numberOfPlayers’ to one. o A constructor with one integer parameter. Said parameter’s value is to be assigned into ‘numberOfPlayers’  Note: We’ll assume it’s always between one and four (inclusive). Important: Not only must both constructors define the ‘players’ array (whose size is directly proportional to the number of players), both constructors must propagate said array with [new] objects based on class ‘Bowler’s default constructor.  Once again, the number of instantiations / assignments should be dependent on the number of players. One for one, two for two, etc. • Methods: 1. A standard accessor function for ‘numberOfPlayers’ called “getNumberOfPlayers” (has capital letters ‘N’, ‘oh’, and ‘P’).  Note: No need for a mutator method, but if you create one anyway, that’s fine. Just make sure the rest of your code works like normal. 2. An accessor function called “getPlayerHandicap” (first ‘P’ is capitalized, and so is the ‘H’ letter) which has ONE integer parameter.  The parameter value represents a player’s ID number, and so, this function must simply return that particular player’s handicap value. 3. A mutator function called “setPlayerHandicap” (first ‘P’ is capitalized, and so is the ‘H’ letter) which has TWO integer parameters.  The first integer parameter value represents a player’s ID number, and so, this function must simply assign the second parameter’s value into the array’s corresponding player’s handicap attribute. • Note: Can assume handicap argument will always be positive. 4. An accessor function called “getPlayerScore” (with a capital ‘P’ and ‘S’) which has ONE integer parameter.  The parameter value represents a player’s ID number, and so, this function must simply return that particular player’s total score (with the handicap applied). • Tip: Utilize the first “getScore” function from class ‘Bowler’. 5. Overload the “getPlayerScore” function so that it now has TWO parameters (and the same return type).  First parameter is an integer and represents a player’s ID number.  Second parameter is a boolean. • If the boolean value is true, return the same value that the original “getPlayerScore” function would return, otherwise … • If the boolean value is false, return the given player’s score but with the handicap value omitted. • Tip: Utilize the second “getScore” function from class ‘Bowler’. 6. A function called “setOneFrameScore” with THREE integer parameters.  Note: Return type is void and the identifier uses capital ‘oh’ for “One”, capital ‘F’ for “Frame”, and capital ‘S’ for “score”. • The first parameter represents a player’s ID number. • The second parameter represents a particular frame number (between, and including, one and ten). • The third parameter represents a (presumably positive) score.  When invoked, this function must change the corresponding player’s corresponding frame’s score to be whatever value the new score is. • For example, if the function call is “setOneFrameScore(1, 2, 3);”, then Player #2 (at index one) needs to have its second frame score (at index one) be assigned the value of three. 7. A void function called “setAllFrameScores” with TWO parameters: the first an integer, the second an integer array.  Note: Can assume the array argument’s size is always exactly ten.  The first parameter value represents a player’s ID number, and so, this function will simply assign all the values from within the array parameter into the player’s corresponding frame scores. • The first integer element will be used for Frame #1 (at index zero), the second integer value will be used for Frame #2 (at index one), etc. 8. A function, with an integer return type, called “winningPlayer” (spelled with a capital ‘P’) which has NO parameters.  Comparing all the current total scores (with handicaps applied) amongst all active players, this function must return the ID number of whichever player has the highest score. • Return zero for Player #1, return one for Player #2, etc.  Note: If two or more players are tied, any one of their IDs will do. 9. A function, with an integer return type, called “winningPlayerScore” (spelled with a capital ‘P’ and ‘S’) which has NO parameters.  Does the same thing as function “winningPlayer” but will instead return said player’s total score (with the handicap applied). 10. A function called “displayOnePlayerScore” with ONE integer parameter.  Note: Return type is void and the identifier uses capital ‘oh’ for “One”, capital ‘P’ for “Player”, and capital ‘S’ for “score”.  The parameter value represents a player’s ID number.  When invoked, this function will print out all information about the given player. The format of the text and output can be whatever style you’d like, so long as all of the following information is presented: • The player’s ID number (or their order in the game). • The player’s handicap value. • All ten of their frame scores. • The total score WITH the handicap applied. • The total score WITHOUT the handicap applied. o Note: If handicap is zero, printing the score just once will do. • Visual Aid: See last page for an example. 11. A void function called “displayAllScores” with no parameters.  Same thing as the “displayOnePlayerScore” function but now does so for every single player (again, see last page for an example). give me in java code
java
java
java
Explanation
The provided Java code defines two classes, Bowler and Bowling_Game, with the specified attributes and methods as per the homework instructions. The main function tests the functionality of these classes by creating a game instance, setting frame scores and handicaps for players, and displaying the scores and the winning player's information.
Step-by-step Instruction
Define the Bowling_Game class with private attributes and public methods, including constructors to initialize the players array and methods to access and modify player data
Implement the main function to create an instance of Bowling_Game, set frame scores and handicaps, and display the scores and winning player information
Time Complexity
The time complexity for calculating the score is O(n) where n is the number of frames, as it requires iterating through the frameScores array. The time complexity for finding the winning player is O(m) where m is the number of players.
Space Complexity
The space complexity is O(m * n) where m is the number of players and n is the number of frames, due to storing scores for each player in an array.
© 2023 AskSia.AI all rights reserved