Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


Foundations of C++

Assignments 2 and 3 – Pairs Card Game


MCD4720 - Fundamentals of C++

Assignment 2 and 3 - Trimester 2, 2020


Submission Instructions:

This project will be submitted in two parts:


 Assignment 2 – Part A: consists of your project planning documentation.

This document will include an outline of your program structure and UML Class diagrams.

The assignment must be created and submitted as a single Word or PDF document to the Moodle site. This document must clearly identify both your Name and Student ID to facilitate ease of assessment and feedback.

Your document file MUST be named as follows:

YourFistNameLastName_A2.docx” or “YourFistNameLastName_A2.pdf”.

This file must be submitted via the Moodle assignment submission page.

The document should contain the project plan and the UML diagrams. You can use Microsoft Visio to draw the UML diagrams or you can use any other software, provided that the diagrams are included in your submitted document.

Explicit assessment criteria are provided, however please note you will also be assessed on the following broad criteria:

Detail of a proposed project plan for the overall project.

Creating accurate and complete UML diagrams.

Applying a solid Object-Oriented Design (OOD) for the overall project

Using appropriate naming conventions, following the unit Programming Style Guide.


Assignment 3 – Part B: consists of your implementation of your game project.

Your project must follow your project plan and must be submitted as a Visual Studio project, including all header and code files, and any appropriate text files to ensure the program compiles and runs.

You may complete the tasks in your preferred IDE, however you MUST create a Visual Studio project in order to submit. Your project folder must be identified by using your name and assignment number, such as YourFirstNameLastNameID_A3.

The entire project folder must then be zipped up into one zip file for submission. The zip file MUST be named “YourFistNameLastName_A3.zip”. This zip file must be submitted via the Moodle assignment submission page.

Explicit assessment criteria are provided, however please note you will also be assessed on the following broad criteria:

Meeting functional requirements as described in the assignment description

Demonstrating a solid understanding of C++ concepts, including good practice

Demonstrating an understanding of specific C++ concepts relating to the assignment tasks, including object-oriented design and implementation and the use of Pointers

Following the unit Programming Style Guide

Creating solutions that are as efficient and extensible as possible

Reflecting on the appropriateness of your implemented design and meeting functional requirements as described in the assignment description



Assignment 2: Farkle (Part A)

You are to implement a computer-based variant of the dice game Farkle. This is a dice game for any number of players. Each player is racing to reach a target score by removing scoring combinations of dice from a set of 6 dice. The first player to reach or exceed the target score is declared the winner! Any number of players may play, however, for the basic assignment you only need to implement one.

You can watch a video on how to play here: https://www.youtube.com/watch?v=jBKdOF9tuog or even play an online version here: http://www.playonlinedicegames.com/farkle 

In your version, for the basic assignment you only need to implement a 1-player game.

For Assignment 2 (Part A) of the assignment you will focus on the planning of the project. In Part B you will focus on creating the various interactive objects in the game and program the player interactions.


Basic Game Play:

In this program, you will control a set of six dice. On your turn, you must make as many scoring combinations (as outlined below) as you wish to score points towards the winning target score.

The basic game play is as follows:


One player is playing with themselves each time must track their own score and display their name and game score when required



On your turn:


■ Roll all six dice and set aside at least one die of a scoring value, (as shown below): Note you should follow the below scoring guidelines even the YouTube and the online game said something else.



Combinations only count when made in a single throw.

■ You may now decide whether to score your points and end your turn or you can re-roll the remaining dice.

If you choose to roll again, you can keep rolling the dice, until you choose to stop or you roll no scoring values. Rolling no scoring values is called a FARKLE.

If you roll a FARKLE, you score NO POINTS for this round and your turn ends. Pass the dice to the next player.

If you set aside all 6 dice, you may re-roll all 6 dice and continue adding to your score, following all the rules above.

The first player to score 10,000 or more points wins the game. However, for this assignment set a 5,000-point target score.

There are many variations to this basic game, some of which you will be able to implement as part of the extra functionality for your assignment.


A Typical Player Turn:

During a player’s turn, the logic is as follows:

1) First, the player must roll all 6 dice to produce 6 random numbers from 1-6.

2) Next, they set aside at least one die that scores points (a single 1 or 5, or 3-of-a-kind). The points for which are stored in a running total for the player’s turn. These dice cannot be rolled again, until after all 6 dice are set aside (see Step 4).

3) The player is presented with 2 options – roll the dice or score their points.

If they choose to score, the running total is added to their player score and their turn ends.

If they roll again, only those dice not set aside are rolled. Steps 2 and 3 may be repeated as often as the player wishes, until they use all 6 dice (Step 4) or roll a Farkle (Step 5).

4) If the player sets aside all 6 dice, they may choose to start again with all 6 dice and continue scoring as before. Steps 2 and 3 may be repeated as often as the player wishes.

5) A Farkle is a roll with no scoring values – the player cannot take a single 1 or 5, or 3-of-a kind. When this happens, the player ends their turn immediately and does not score the points rolled during that turn. Their saved score is not changed.

Here is an example roll for a player’s turn:


On their first roll, the player rolls a 1, 2, 3, 3, 5, 5.

They can score 100 points for the 1, or 100 points for both the 5s, or 50 points for 1 of the 5s, or 200 points for the 1 and both 5s.

They choose to set aside just the 1 for 100 points and roll the 5 remaining dice again.

This time they roll a 2, 3, 6, 6, 6. They decide to take the 600 points for the 3-of-a-kind in 6s.

Their running total is now 700 points. This is a good score so they opt to save their points and end their turn.



Project Plan

Having a clear plan for your project before you begin coding is essential for finishing a successful project on time and with minimal stress. So, part of this assignment is defining what will be in your project and what you need to do to actually develop it.

Important: You must also read the requirements for Assignment 3 in order to be able to complete the documentation required for Assignment 2.

The documentation you must submit will include the following:

✓ A description of “How to Play”

This will be the information you display on the opening screen of your game to inform the player what they need to do in order to play and win the game. Do not just copy the game play description above, make your own description.

Note: This description must be saved as a text file and read into your game when the program begins. You can also use this as a convenient way to display “help” if the player asks for it.

✓ A development outline of your game

Using a simple outline format (numbered or bullet points) state the main actions that the program will have and then, as sub-points, state the things you will need to do to make that happen.

The outline structure should contain all the elements of your game, as this is a high-level description of your approach to the development of your program. You should include at least the following headings and provide examples of happens under each section.


The game setup (everything that happens before the game starts)

The player’s turn (the sequence of events that happen during a turn)

Processing player input (include each of the commands your player can use)

Providing feedback to the player (in response to the player’s interactions)

The end game conditions (include all win and lose conditions)

Additional Features included, if any – see Assignment 3

Outline the functionality of all your game classes – see Assignment 3


Here is an example to get you started with your project outline:

○ The Game Setup

Display an overview of the game rule so the player knows what to do to win.

■ read this information from a text file

Initialise the game elements:

■ add the player – ask for the player’s name, set default variables

■ all the other things that will happen during initialisation including

● creating the game board

● initialising other game variables (list them here)

As you can see, you only have to describe the actions the program will take, not the code, for the outline. The idea here is to give you a starting point for when you start writing your code as you can use this as a checklist of the things you need to include.

✓ UML Diagrams

UML diagrams are designed to make structuring your program easier. How to create them will be covered in class, but the general structure is shown here – see Assignment 3 for more details about classes.

You will need UML diagrams for each of the classes you include in your game – at least a Player, Board and Application (main) class.

  ClassName
  list of attributes
  (variables)
  list of behaviours
  (functions)


Assignment 3: Farkle (Part B)

You are to implement the Farkle dice game you started in Assignment 2 by creating a Visual Studio Project using your project plan as described in your previous submission.

Your completed Farkle dice game must demonstrate the following:

You MUST implement your program using the following classes, as a minimum, you may include more (as appropriate for your game design):

Player class: holds a player’s details including their name, score and turns taken.

Die class: holds the current die value, a visual representation of the die and whether it can be rolled (or not).

Application file: holds the main() function and controls the overall flow of the game.

You may include other relevant attributes and behaviours to these classes, as identified in your project plan.

The Player must be able to do the following:

assign a name which is requested at the start of the game and used in the feedback given

choose to roll or score the dice rolled and see appropriate feedback as a result

continue rolling dice until they win or lose the game

■ a win = reaching or exceeding 5,000 points

■ a loss = rolling 3 Farkles in a row

quit the game at any time – during or after a game

The Dice in the game should have the following characteristics:

be set to a random number from 1 to 6 with each roll

if the die is selected, it should be locked and unable to roll again

be able to reset the die value to 0 at the end of a turn when the player scores their points

display a rolled value and a locked version (eg: [1] = a rolled 1 and [x] = a locked die)

The Game Application must do the following:

display the “how to play” information at the start of the game

create a player and a set of 6 dice

display an appropriate and uncluttered user interface providing relevant information to the player at all times

ask for and allow the player enter an option to roll the dice or score the points

ask for and allow the player to select one or more of the rolled dice

display the updated dice after each roll entered by the player

terminate the game (player wins) when the player has reached or passed the target

terminate the game (player loses) when the player has rolled 3 Farkles in a row

provide player stats at the end of the game (wins, loses and score)

the player should be able to QUIT the game at any time


Program Reflection

You must also provide a 300-word written reflection of your object-oriented design and how well you believe it was to implement. You should cover the following areas:


Discuss why you designed it the way you did.



■ Why did you create your classes that way?



■ How does this reflect an OO design or approach?



Discuss how well you were able to code it



■ Highlight any issues you found once you tried to implement your design.



■ How did you resolve these issues?



If you were to do this project again, discuss how you might change your design to make your solution easier to implement, more efficient, or better for code reuse.

The extra functionalities you applied.


This must be a Word or PDF document which must be included in the same folder as your *.sln file. Your document file MUST be named as follows:

A3-YourFistNameLastName.docx” or “A3-YourFistNameLastName.pdf”.


Extra Functionality

The marking criteria indicates that you should make some individual additions to this in order to achieve the final 15% of the mark.

Following is a list of additional features you can include, with the maximum number of marks [x] you can earn for each one. You may implement one or more features from the list, but you will only score up to the maximum of 15% of the total assignment marks or 15 marks.

You should aim to add some additional creative elements to the gameplay, as well as advanced object-oriented design elements or advanced use of pointers.

The player selects a skill level (eg: Rookie, Roller and High Roller) which modifies the game parameters – the target score (5,000, 10,000 and 20,000) and the minimum points required to roll before saving points (250, 500 and 750 respectively), etc. [5]

If a player rolls three Farkles in a row (on three consecutive turns) they lose 1000 points from their saved score (can go negative). Once they lose the points the counter for Farkles is reset to zero. If a single player then rolling 3 Farkles in a row will lose the game if their score becomes negative. [5]

Include multiple human players making the game playable by 1 to 4 people. At the beginning of the game the player order must be randomised. Each player must track their own score and display their name and game score when required. One player is randomly chosen to go first. Players take turns in clockwise order. The game is played in rounds in which each player has a turn to roll the dice and score points. [10]

Display the dice using ASCII art, showing the faces as pips not as numbers. [8]

Allow the game to be saved and restored at the player’s request. [8]

Ask the player if they want to be promoted to the next skill level after winning 5 games. If they accept their skill level is increased by one (to the maximum level permitted in your game). Also, if the player loses 5 games in a row they are automatically demoted one skill level (to the minimum level permitted in your game). [8]

When the first player reaches or exceeds the target score, all other players (in a multi-player game) have one final turn to try and beat that score. In this case, the player at the end of the round with the highest score wins. [8]

Have a main menu at the start of the program (includes minimum 5 options) [5]

A text file includes all extra functionalities that you have implemented can be viewed when an option from the main menu is selected or just displayed when the program starts. [5]

Allow the game to be played with computer players. The computer player should be able to make reasonably intelligent decisions for choosing scoring combinations and when to save their points. This AI can be a set of rules that the computer player checks before making a roll or when to save their score. On a computer player’s turn, the process should be automated so that the human player can watch the results. [10]

Implement a more sophisticated AI for the computer players. You may create different player types, each with their own strategies for playing, such as an easy player, a cautious player, an aggressive player, etc. The human player should be able to select the level of difficulty and number of their opponents at the beginning of the game. [10]

You certainly do not have to implement all of the above to earn marks for extra functionality. Just remember the maximum number of marks you can earn are given in [x]. It is up to you!