Page 1 of 1

For this assignment, you are required to program the same game as Assignment 2, but instead of using an immutable string

Posted: Sun May 15, 2022 1:54 pm
by answerhappygod
For This Assignment You Are Required To Program The Same Game As Assignment 2 But Instead Of Using An Immutable String 1
For This Assignment You Are Required To Program The Same Game As Assignment 2 But Instead Of Using An Immutable String 1 (459.49 KiB) Viewed 113 times
For this assignment, you are required to program the same game as Assignment 2, but instead of using an immutable string object for representing a coin strip, we will use a list of string objects to represent a coin strip. For example, the following represents the initial coins list: ['-', '$', '$', '-' '$', '-'] All game rules are exactly the same as for Assignment 2. However, your program is required to: • validate the position number, and • validate the number of positions to move entered by the user. Your program has to check if the move is valid. (i.e. the coin ends up in an empty location and never on or passes another coin). Note: you can assume that all input are integers. You are required to complete the following functions: • The display_banner() function • The get_position_number_from_user() function • The get_number_places_to_move() function • The get_next_player_num() function • The congratulate_player() function • The display_coins_list() function • The check_game_finished() function • The move_random_character_to_end() function • The create_coins_list() function • The validate_index() function • The validate_move() function • The move_dollar_to_the_left() function

Question 2 Precheck results Complete the display_coins_list(coins_list) function. This function takes a list (always nine elements in length) as a parameter. The function displays 3 lines in total. An example of the output is as shown below: Marked out of 1.00 123456789 $ $$ $ P Flag question • The first line shows the digits 1 to 9 (as indicated in the example output above). • The second line shows a single line of 9 "-" symbols (hyphens). • The third line shows the coins list, formatted as in the examples. _ For example: Test Result display_coins_list(['-', '$', '-', '$', '-', '$', '-', '-', '$']) 123456789 | -$-$-$--$ -', '-', '-', '$'] 123456789 data = ['$', '-', '$', '-', '$', display_coins_list(data) $-$-$---$

Question 3 Not complete Complete the check_game_finished (coins_list) function. The function takes the coins list as a parameter and returns True if the game is finished and False otherwise. The game is finished when the 4 "$" symbols are in the first 4 positions of the coins list. For example: Marked out of 1.00 P Flag question Test Result print(check_game_finished(['-', '$', '-', '$', -', '$', '-', '-', '$'])) False print(check_game_finished ( ['$', '$', '$', '$', -', '-', -', '-', '-'])) True

Question 4 Precheck results Complete the move_random_character_to_end (coins_list) function. This function takes the coins list as a parameter. The function generates a random position in the list, removes the element at this random position and adds the random element to the end of the parameter list. Marked out of 1.00 Note: Flag question • The function makes changes in place. (i.e. it changes the list that is passed to the function. It does not create a new list, and it does not return anything). • Do not import the random module. This has been done for you as part of the CodeRunner question. For example: Test Result ['$', '-', 'S', '-', '$', '-', '-', 's', '-'] random. seed (10) data = ['-', '$', '-', '$', '-', 'S', '-', '-', '$'] move_random_character_to_end(data) print(data) ['$', 's', 's', '-', '-' '-', '-', '-', 's'] random. seed (20) data = ['$', '$', '$', 's', '-', '-', '-', '-', '-'] move_random_character_to_end(data) print(data) ['$', '-', '-', '$'] random. seed (60) #extra test case to check the range data = ['$', '-', '$', '-'] move_random_character_to_end(data) print(data)