Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Assignment - Individual programming assignment

Programming Principles

Background Information
This assignment tests your understanding of and ability to apply the programming concepts we have covered in the unit so far, including the usage of variables, input/output, data types, selection, iteration, functions and data structures. Above all else, it tests your ability to design and then implement a solution to a problem using these concepts.

Assignment Overview
You are required to design and implement a program that allows the user to play a single-player dice game based loosely on the game "Farkle" (although you do not need to be familiar with Farkle). The game is played as follows:
• The game consists of 3 turns, and the aim of the game is to score as many points as possible

• Each turn begins with a roll of 6 standard dice

• Matching dice (2 or more of the same number) can be set aside for points, and the
remaining dice can then be re-rolled in an attempt to score more points
- Points are "amount of dice * number on dice", e.g. rolling three 5s is worth 15 points

• The player chooses whether to set matching dice aside and whether to re-roll remaining dice

• If the player chooses not to re-roll the dice, the points accumulated in the turn are added to their score and the turn ends

• If no dice can be put aside after a roll, the player loses the points the potential points and the turn ends - hence, the player must decide how far to push their luck with additional rolls

The game involves quite a lot of luck, but there is also a small amount of strategy in choosing whether to set matching dice aside and whether to re-roll the remaining dice.

The entirety of this program can be implemented in under 100 lines of code (although implementing CSP5110 requirements or optional additions may result in a program longer than this) - Ask your tutor for advice if you feel your program is unusually long or inefficient.

Pseudocode
As emphasised by the case study of Module 5, it is important to take the time to properly design a solution before starting to write code. Hence, this assignment requires you to write and submit pseudocode of your program design as well as the code for the program. Furthermore, while your tutors are happy to provide help and feedback on your assignment work throughout the semester, they will expect you to be able to show your pseudocode and explain the design of your code.

You will gain a lot more benefit from pseudocode if you actually attempt it before trying to code your program - even if you just start with a rough draft to establish the overall program structure, and then revise and refine it as you work on the code. This back and forth cycle of designing and coding is completely normal and expected, particularly when you are new to programming. The requirements detailed on the following pages should give you a good idea of the structure of the program, allowing you to make a start on designing your solution in pseudocode.

See Reading 3.3 for further information and tips regarding writing good pseudocode.

Since the structure of this program is relatively complex, a broad overview has been provided below:

For each turn
Reset dice and points For each roll
Roll remaining dice
Find matching dice and prompt user to set them aside If no dice set aside
End turn without adding points to score Else
Ask user whether they want to roll again or end turn

If user ends turn
Add points to score and end turn Else
Continue to next roll

Show end of game messages

Write a separate section of pseudocode for each function you define in your program so that the pseudocode for the main part of your program is not cluttered with function definitions. Ensure that the pseudocode for each of your functions clearly describes the parameters that the function receives and what the function returns back to the program.

It may help to think of the pseudocode of your program as the content of a book, and the pseudocode of functions as its appendices: It should be possible to read and understand a book without necessarily reading the appendices, however they are there for further reference if needed.

Only one function is required in this assignment (detailed later in the assignment brief).

Program Requirements
Below are the detailed requirements of the program you must implement. In the following information, numbered points describe a core requirement of the program, and bullet points (in italics) are additional details, notes and hints regarding the requirement. Refer to the earlier information or ask your tutor if you do not understand a requirement or would like further details.

1. The game consists of 3 turns. At the start of each turn, print a message indicating which turn it is and the user's current score.
- At the start of each turn, set the number of remaining dice to 6, and the points earned this turn to 0.

2. In each turn, there are an unknown number of rolls. For each roll, firstly simulate rolling the remaining dice by producing a list of random integers between 1 and 6.
- The amount of numbers in the list should match the number of remaining dice.
- Sort the list so that the rolled numbers are in ascending order using the ".sort()" list method.
- Print the sorted list of numbers for the user to see.

3. Check the rolled dice for matching numbers (i.e. 2 or more of the same number). For each set of matching numbers, print the details of the match and the points it is worth, then use the "getChoice()" function (detailed below) to prompt the user to decide whether they wish to set those dice aside by entering "yes" or "no".
- One approach is to loop through the numbers 1 to 6, using the ".count()" list method to determine how many of each number appears in the list of numbers.

4. If the user chooses to set aside matching dice, subtract the number of dice from their remaining dice and add the points that the matching dice are worth to their points.
- Points are simply "amount of dice * number on dice", but remember that the points a user earns during a turn are not added to their score until they choose to end the turn.
- If the user chooses not to set the dice aside, no change is made to the number of dice or points.

5. If no sets of matching dice were set aside in this roll, continue to the next turn without adding the points to their score.
- A boolean variable can be used to keep track of whether or not any dice have been set aside.
- It is possible (although not very clever) for the user to roll matching dice and choose not to set any of them aside, causing the turn to end.

6. Otherwise, tell the user how many dice are remaining and their current points, and then use the "getChoice()" function (detailed below) to prompt the user to decide whether or not to re- roll their remaining dice or end their turn by entering "roll" or "end".
- It is possible (although again, not very clever) for the user to choose to re-roll when they have fewer than 2 dice remaining. Accounting for this is a CSP5110 requirement.

7. If the user chooses to end their turn, add the points to their score and continue to the next turn. If they choose to re-roll the remaining dice, perform another roll (repeat from Requirement 2).

8. At the end of the third turn, print a "game over" message and their final score. Then, print an additional message if they achieved a score above the following thresholds:
- If their score is at least 60, print "Excellent score, well done!"
- Otherwise, if their score is at least 50, print "Great score!"
- Otherwise, if their score is at least 40, print "Good score!"
- Otherwise, do not print anything.

Attachment:- Tips.rar

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92426028
  • Price:- $140

Guranteed 48 Hours Delivery, In Price:- $140

Have any Question?


Related Questions in Programming Language

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As