COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Assignment 3 – Uno

Posted by on September 25th, 2011 · Assignments

Due Date: Sunday week 12 (23:59:59 16 October 2011)

Your final assignment is to complete an implementation of the game of Uno. The focus of the assignment is on using inheritance. You will also be required to write unit tests for you code to demonstrate its correctness.

Background

To start the project, download the BlueJ package for Assignment 3. In it you will find three classes:

  • UnoGame – This class implements the rules of the game.
  • Player – This class implements a fairly stupid AI player.
  • Card – This class implements a standard number card.

You should NOT change the source of any of these classes.

Your job is to create five new classes, all extensions of the Card class:

  1. DrawCard – This card causes the next player to draw a number of cards (designated in the constructor) and miss their turn.
  2. SkipCard – This card causes the next n players to miss their turn (for a number n designated in the constructor)
  3. ReverseCard – This card causes the direction of play to reverse.
  4. WildCard – This card can be played at on any other card. It changes the colour randomly.
  5. WildDrawCard – A combination of the Wild and Draw cards.

The rules of Uno

You can read the rules of Uno here. The existing code already implements these rules for standard numbered cards, you just have to extend it to the cards above. Note in particular that Draw, Skip and Reverse cards all have a colour like normal number cards, and can only be played on cards of the same colour or on another Draw, Skip or Reverse (respectively). Wild cards, on the other hand, do not have a colour and can be played on any other card.

For this assignment we are implementing a game with no human players, so you do not need to worry about how to handle input. For this reason, we will assume the Wild cards change the colour randomly.

Constructors and Methods

Your classes shoud have the following constructors:

  • SkipCard(int colour, int nSkip) Create a skip card with the given colour that skips nSkip players.
  • ReverseCard(int colour) Create a reverse card with the given colour.
  • DrawCard(int colour, int nDraw) Create a draw card with the given colour which makes the next player draw nDraw cards.
  • WildCard() Create a wild card (no colour specified).
  • WildDrawCard(int nDraw) Create a wild card (no colour specified) that causes the next player to draw nDraw cards.

Your classes should override the canPlayOn and play methods in Card as necessary in order to implement their functionality.

Unit testing

Each of the classes provided in the assignment have associated unit tests. You are required to implement further unit tests for the classes you have created, demonstrating that they work as required. Your unit test classes should be named:

  1. SkipCardTest
  2. ReverseCardTest
  3. DrawCardTest
  4. WildCardTest
  5. WildDrawCardTest

Do not change any of the existing test classes.

Marking

Your mark will be based 50% on the correctness of you code, 30% on testing and 20% on style.

If the assignment is submitted late, 10% will be taken off the maximum make per day, to a maximum of 7 days.

Submission

You will be submitting your solutions online, by the following steps:

  1. Select “Create Jar File…” In the Project menu in BlueJ.
  2. In the dialog box make sure the “Include source” box is checked.
  3. Press Continue
  4. Save with the filename “ass3.jar
  5. Go to https://cgi.cse.unsw.edu.au/~give/Student/give.php
  6. Login with your CSE username and password
  7. Type COMP1400 in the Course field and press Search
  8. Select ass3 from the list of assignments and press Upload my assignment
  9. Select Browse to locate your ass3.jar file.
  10. Press Submit my files.
  11. Check the response to make sure your submission was processed correctly.

NOTE: You can submit as often as you like. Only the last submission will be marked. Do NOT leave it to the last minute. No sympathy will be given if you leave submission until midnight Sunday and something goes wrong. It is good practice to make multiple submissions as you go.

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.