CS 170 Lab 12: Creating a Class

This lab will get you started with Object-oriented programming and get you started with code for Program 4. In these assignments we will be exploring a simple form of Poker with dice. For this lab we will be defining the Dice class that will be the basis for the program.

Start with the file Dice.py which defines the Dice class. We will discuss the details during the lab, but this class has a few methods already defined for you, including the __init__ method, which is the special method that is called automatically whenever you create an object of this class. To create a Dice object do something like:

d = Dice()
after choosing Run Module from the Run menu. This will give you a Dice object in the variable d. You can invoke the other methods on this object. For example:
>>> d.values()
[1, 1, 6, 1, 2]
>>>
will show you the randomly generated dice values (presumably different for each Dice object you instantiate).

Your task for this lab is to fully instantiate the score() method so that it scores the Dice values the way the comment says it should. Your function should always return two values, a string that describes the best interpretation of the dice values and the associated score. For now it always returns "Garbage", 0 which is only occasionally the right answer.

When you are convinced that your code is correct, well-documented and your name is in the file, you should upload the file.

Make sure your file has your name and Lab 12 prominently displayed on it.