Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE PYTHON CODING class Coin: #This class lets us create Coin objects showing_heads=True #By default the coin shows heads value=1#By default the coin has the

USE PYTHON CODING

class Coin:

#This class lets us create Coin objects

showing_heads=True #By default the coin shows "heads"

value=1#By default the coin has the value 1p

def show(self):

#Returns a string to incicate which face of the coin is showing

if (self.showing_heads==True):

return "Heads"

else:

return "Tails"

def turn(self):

#Turns the coin over

self.showing_heads=not self.showing_heads

Using the code shown above as a base write a code to do the following:

- Create two coin objects coin1 and coin2

- Demonstrate that they are both show() Heads

- Demonstrate that if you turn() either of them they show Tails

- Add a new member function to Coin called setValue which sets value attribute of a coin

- Add a new member function to Coin called getValue which returns the value attribute of the coin as an integer

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago