Programming Assignment #1 CS 202 Programming Systems
We do not accept late work beyond the late date. No exceptions.
When beginning with this project, the first thing to keep in mind is that we are no longer working on CS163 programs! In CS163 we were concerned about creating Abstract Data Types and the class construct facilitated this. Instead, this term we will be focusing on how to create Object Oriented Solutions. An ADT may be part of that solution – but it certainly shouldn’t be the primary focus. Instead you want to strive for classes to have specific “jobs” and have classes derived from more general classes, whenever appropriate. We will be working in situations where there are multiple classes, so you will want to focus on dividing the design into smaller components that have specific jobs working together to solve the problem.
This term, programs 1 and 2 are a single design with a given theme. Program 2 will build on top of program #1. For these first two assignments, we will start with an Object Oriented (Topics #1 and 3) program for playing a game similar to Sorry (we will call it CS_Sorry but you can pick a different name!) but with a few different rules. Then, in program #2 we will extend this to allow for a data structure to support playing different games using a new concept called Dynamic Binding (Topic #4).
For program #1, a player begins at the Start of the game with two pawns, and progresses each through a maze of “spaces” (or locations). Players move based on cards that are drawn. These will cause the player to move forward or backward a given number of spaces. Unexpected events happen when a player lands on a particular kind of space. To win you must exactly reach the End of the maze with each of the player’s pawns.
What sets this apart from the real game of “Sorry” is that it instead of a single path from the start to the end, we will now support a maze of possible paths from start to end based on your game’s board. Each time the player plays the game, a different board (or maze) should be generated (through the use of a random number generator). The cards available to be drawn should also be shuffled using a random number generator.
For Program #1, you will be creating an object oriented program that will progress a player’s pawns through a CS_Sorry game.
Summer 2019 Programming Assignment #1
Allow for at least two players.
Use an external data file to store the information about cards (please do not hard code the data in the program!)
*** Make sure to read the Background Information first! It applies to all programming assignments this term***
c. Support at least the following cards:
a. Move forward one, two, or four spaces
b. Move backward one, two, or four spaces
c. Move forward to the next fork to the left
d. Move forward to the next fork to the right
e. Send the other player to your previous location
ideas with any other classmate! I am looking for very unique ideas.
create 2 different cards that are uniquely of your creation. Don’t share your
e. Support at least two spaces that have purpose:
a. Go back to Start (so if the player’s pawn lands on this space, they have to
restart that pawn at the beginning)
b. Create one other purpose (e.g., exchange locations with another player, slide
backwards to a given space, etc.). Have some fun with this!
f. You can decide how many cards a player draws and what happens if no cards can be played (typically if no cards can be played then the player misses their turn and
discards a card).
To make this Object Oriented:
You will want to first think about breaking this down into a series of classes and create them independent of the entire problem. Here are some suggestions to start with. With hierarchies always push the common elements up to the base class.
Remember to avoid classes with only setters and getters! Instead think about what functions would make sense for each of these classes and really give them a purpose. Start small and incrementally implement this.
1. Card – there are cards that are forward cards and backwards cards (think hierarchy!)
2. Player – A player has a name plus four pawns
3. Pawn – A pawn is at a particular location (space) on the board
4. Space on the board – where the maze has multiple spaces
5. A maze of spaces – implementing using a data structure (see below)
6. Have at least 5 classes! And, nodes will need to be classes instead of structs
Anything that is similar between these or other classes should be pushed up to be part of a base class. Keep classes small and functions small. A large class or function means that the problem has not yet been broken down into its basic components (objects).
The following are the data structure requirements:
1. An array of linked lists is required to represent the maze. It will be important to
prepare for program #2 by having each node have a POINTER to a Space on
2. The deck of cards should be a circular linked list
3. Recursion MUST be used rather than iteration for data structure algorithms!
4. FULL implementations of your data structures are expected (insert and removal)
CS202 Summer 2019 Programming Assignment #1