CS 162 Spring 2000 Assignment 2 – Object-Oriented Programming with C++ - Modifying A Program 100 points

Assigned: 02/07/2000

Due: 02/14/2000 at the start of class.

Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk. Plan out changes and additions of statements needed for program.

Pairs: You may work in pairs if you want. Note, during the course of the semester, you cannot pair with any one person more than twice. If you work in a pair, turn in ONE copy that is the work of both of you, with both of your names on it. Each member of the pair will receive the same grade for that lab. In such a partnership, students must share as equally as possible the work and learning. Working together with truly shared effort and learning can be a positive experience. However, simply giving/receiving code from someone defeats the learning process. If substantial parts of a program are taken from non-partners, that is plagiarism. The copier and copyee will each receive a zero.

Main Assignment:

Update the War program from the textbook, making changes and enhancements. 1) Fix the program so that Aces count as high. 2) Fix the program so that the user’s response to "Run Fast?" question is validated to ensure user types Y or y or N or n; 3) Add the normal tie procedure – three down cards then tie broken by each player’s fourth card. (since we are not displaying cards, you do not have to update the Card class to indicate right-side up or upside down). Take the down cards out of the player’s hand, replacing each as it is taken out.

Details:

  1. This may be the first time that many of you have modified somebody else’s program. The challenge should reinforce how important good programming practices are. Would you want to update a version with no comments?
  2. Hand-in:

    1) Listing of the program

  3. Disk with your .cpp file and your working .exe file. NAME YOUR PROGRAM FILE yourlastnamewar2.cpp; Name your project yourlastnamewar2 so that the executable will be yourlastnamewar2.exe. If you are working in pairs, use both last names (e.g. redmondsmithwar2.cpp)

Miscellaneous:

1) If you have any questions about what should be done, please ask!!

2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Test it more than once - I will!

3) Remember: Indentation, meaningful variable names, symbolic constants, and meaningful comments. Weaknesses in any of these could result in points off. Also make sure you put YOUR NAME(s), section, and e-mail address in comments at the beginning of the program.

4) You will want to chose to not "run fast" while debugging your program.

5) The "demo randomInteger" output is unnecessary, but the currently available code has it in. No need to remove it.

Sample Interaction:

Demo randomInteger () operator 41 7 42 32 33 20 38 30 26 24 37 13 37 31 29 23 31 34 43 28 47 44 2 49 32 6 1 48 10 31 39 42 3 46 49 48 31 39 31 14 51 47 18 17 45 36 9 15 17 4 15 32 6 49 17 15 39 17 21 50 44 19 38 22 28 50 44 50 24 28 42 41 30 21 34 10 30 5 5 12 25 39 8 38 36 36 26 44 47 48 44 43 30 39 25 10 50 2 49 5

Run fast? (y or n) y

Player 1 plays 5 of Diamonds

Player 2 plays 2 of Diamonds

Player 1 wins round

Player 1 plays 7 of Spades

Player 2 plays Queen of Clubs

Player 2 wins round

Player 1 plays 7 of Hearts

Player 2 plays Ace of Diamonds

Player 2 wins round

Player 1 plays 8 of Spades

Player 2 plays 3 of Spades

Player 1 wins round

Player 1 plays 3 of Hearts

Player 2 plays King of Clubs

Player 2 wins round

Player 1 plays 5 of Hearts

Player 2 plays King of Hearts

Player 2 wins round

Player 1 plays 4 of Spades

Player 2 plays Ace of Hearts

Player 2 wins round

Player 1 plays 2 of Spades

Player 2 plays Ace of Spades

Player 2 wins round

Player 1 plays Queen of Hearts

Player 2 plays 9 of Hearts

Player 1 wins round

Player 1 plays 7 of Diamonds

Player 2 plays 9 of Diamonds

Player 2 wins round

Player 1 plays 10 of Spades

Player 2 plays 10 of Clubs

Players tie

Player 1 upside down card: Queen of Diamonds

Player 2 upside down card: 5 of Spades

Player 1 upside down card: 4 of Clubs

Player 2 upside down card: 8 of Hearts

Player 1 upside down card: 4 of Hearts

Player 2 upside down card: 3 of Clubs

Player 1 plays Jack of Hearts

Player 2 plays 2 of Hearts

Player 1 wins round worth 10 points

Player 1 plays 10 of Hearts

Player 2 plays 6 of Diamonds

Player 1 wins round

Player 1 plays Jack of Diamonds

Player 2 plays Jack of Clubs

Players tie

Player 1 upside down card: 5 of Clubs

Player 2 upside down card: 9 of Spades

Player 1 upside down card: 2 of Clubs

Player 2 upside down card: 4 of Diamonds

Player 1 upside down card: 3 of Diamonds

Player 2 upside down card: King of Diamonds

Player 1 plays Ace of Clubs

Player 2 plays 10 of Diamonds

Player 1 wins round worth 10 points

Player 1 plays Queen of Spades

Player 2 plays 8 of Diamonds

Player 1 wins round

Player 1 plays King of Spades

Player 2 plays 6 of Spades

Player 1 wins round

Player 1 score 32

Player 2 score 14