/A-Coin-Flipper

Worksheet 7 OOP A Coin Flipper

Primary LanguagePython

July 2022 Computing programming course by Teesside University

Worksheet 7-Object-Oriented Programming

[ASSESSMENT] Question 3: A Coin Flipper (class_flip.py) Let’s begin to build some really useful classes that approach problems we’ve faced in previous weeks, starting with a coin flipper.

  1. Create a new class called CoinFlipper with a constructor that takes 1 argument num_of_coins that it stores as an attribute.
  2. Now, add a function to your class called flip() that returns a list containing num_of_coins random Boolean values.
  3. Copy across your answer to the exercise on coin flipping from week 3, and adjust it to use your new CoinFlipper class.
  4. If you haven’t done so already, move your CoinFlipper class into a separate file coinflipper.py stored in the same folder and import it into your solution with from coinflipper import CoinFlipper. You now have a reusable coin flipping algorithm encapsulated inside a class!