CS 202. Object-Oriented programming
To join the CS 202 mailing list.
Enter your e-mail address:
To send/post a message to the CS 202 mailing list,
Explore the CS 202 mailing list at
Read all messages posted.
Find email addresses of other members.
To take yourself off the CS 202 mailing list,
Homework, tests, and code examples
Guess a number.
Modify this program so that it works with warmer/colder clues.
Add a constructor that works with a single number, which is the top of the range. Set the bottom to 1.
Allow the user to play multiple games. For each new game, the user may enter either 0, 1, or 2 numbers specifying no range (default 1 .. 100), an upper limit (lower limit 1) or both the upper and lower limits.
Add operations for inversion (convert to reciprocal), subtraction, multiplication, and division. Write the division operation using inversion, i.e., to divide a number by
, multiply the number by the inverse of
Also add operations for less than, greater than, and equal. These operations do not modify either the object in which they are executing or the argument object. They simply return Boolean (
) values. For these operations, you will have to add prototypes to the .h file as well a implementations to the .cpp file.
Simple Rock, Paper, Scissors
Convert Rock, Paper, Scissors to Prisoner's Dilemma. (You may start with
Simple Prisoner's Dilemma Framework
.) Create an array of
and have them all play against each other. Have the
use a strategy table to determine their moves. Determine the best and worst
and print out the best
strategy table. Also determine the average winnings.
Simple Prisoner's Dilemma with Population
to the Prisoner's Dilemma system. Each
object should contain a collection of
. Instead of keeping an array of
function should have a
variable, which refers to a
object in which the
are kept. Also, instead of determining the winner, loser, and average in the
function, those computations should take place in the
object. Printing the statistics should also occur in the
object. In other words:
Include a constructor that accepts an integer argument that indicates the number of
. The constructor should create a collection (probably an array, but that is your choice) of as many
as the argument indicates. Each
should be initialized randomly, as we currently do.
function that plays each
against each other, as we currently do in
. The argument is the number of games to play in each
function that accepts as an argument a reference to a file outstream and that then prints statistics to that file outstream. The statistics should be the same as we now compute: the winner, its strategy table and amount won; the least amount won; and the average won by all
Generate a sequence of
objects, each one generated from the previous one by selecting the more successful
to be parents of the next
whose strategy table consists of probabilities instead of 'C' and 'D'. The strategy table entry is the probability that the player will play a 'C' on that move. Modify the
class so that you generate
Declare various constants and functions static in the Population, Player, and Match classes.
My home page