Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Technische Universit at M unchen Institut f ur Informatik Tobias Neckel

GRS, June 2013

Python course - Tutorial 3


For those who dont like Black Jack
Implement a class vehicle and two subclasses car and bike. Make sure that vehicle stores the amount of wheels and that the constructors of the subclasses set this value accordingly. Think about other possible properties of the superclass (that all vehicles have in common) and special properties of the derived subclasses; consider also corresponding methods (such as drive() and getNumberOfWheels() or openDoor(). To really understand object oriented programming, it is crucial to practise it yourself!

(simplied) Black Jack


For all those of you who dont know anything about gambling (Hopefully all of you! ;-)): The goal of Black Jack is to draw some cards (from one or several sets of 52 cards) until the value of the cards is as close to 21 as possible, but not above. The game dealer does the same, the one with more points wins. Here, we will play with the following simplied rules: Cards from two to ten have the corresponding value; Jack, Queen and King have a value of 10 and the Ace has always a value of 11 If the player has more than 21, he looses (no matter what the dealer has) If the player has less than 22, and the dealer has more than 21, the player wins Otherwise, a player wins/loses, if he has more/less points than the dealer With equal points, the player neither wins nor looses money We play with six sets of 52 cards You start with 1000 money and will win/loose 1 if you win/loose a game Now the tasks: Download the le blackjack.py from the course webpage and read through the comments (they are docstrings, so you can access them with help)

2 The class PlayerBase describes the methods a class for Black Jack players has to implement. Create a subclass of PlayerBase which implements all described methods and allows you (as a human) to play Black Jack against the already implemented dealer. Implement a second subclass of PlayerBase which implements a computer player without interaction with the user. Send the subclass for the computer player to neckel@in.tum.de by 13:30. If your computer player is the best, youll win a bar of chocolate. Remember that Black Jack is gambling!

You might also like