Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSCI 1511 - Lab 9 CSCI 1511 - Lab 9 Pick one from the list below. Each file should be a python program, root file

image text in transcribed

CSCI 1511 - Lab 9 CSCI 1511 - Lab 9 Pick one from the list below. Each file should be a python program, root file name of "Lab9_pcarswel-\#t", extended by ".py". Insert your username for pcarswel, and the number of the Game Plan: question you chose for 'f. The header of each file should be comments which tell the name of the program, your name [the author], relevant comments, and the date. from coin import Coin 1. Match Coins: Create a coin toss game with two players. Each player starts with def maing) 20 coins. Rules: ask player if they want to play 1. each player tosses their own coin while ' y ' or ' Y ' 2. If the coins match, both players toss their coin 1. Player1 gets Player2's coin. if both coins match 2. If not, the Player2 gets the coin from Player1. 3 . Whoever has the most coins wins. add to player1 and subtract from player 2 else 3. In main(), create a while loop that asks to user to continue play. add to player2 and subtract from player 1 1. In each loop, report the results ... coins matched? 2. Total coins for each player? print results of toss 3. The loop should toss the coins at least once. ask players if they want to play A 'Coin' class is needed. The class requires: a) The methods _init_ = ), toss(), get sideup(), get ameunt(), set_amount() b) The class needs the attributes - amount', initialized to 20, and -sideup? print overall results initialized to one of two values, 'Heads' or 'Tails'. c) 'thass()' method : generates a random value of ' 0 ' or ' 1 ', assigning 'Heads' 2. second problem or 'Tails' accordingly. d) 'get sideupe)' method : returns the current value of _ sidelese. e) 'set ameunt()' method : passes a +1 or -1 to change_-amount, depending on the results of the toss. f) 'getsameuntef' method : returns the current value of_- amount. g) 'spend()' method : you are in Vegas. This method 'zero's' your amount and even assigns a random negative value to your amount. If the amount is zero, you get your hand slapped ... just a little humor. You needn't implement this method. UML diagram for Coin class: (- is private, + is public)

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

Students also viewed these Databases questions