Design and implement a program

Assignment Help Programming Languages
Reference no: EM131617318

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

Reference no: EM131617318

Questions Cloud

What was your dollar return and percent return : If you owned 380 shares of FedEx, what was your dollar return and percent return?
Determine the ratio of the heat transfer rate : Consider a 3-m-high rectangular enclosure consisting of two surfaces separated by a 0.1-m air gap at 1 atm. If the surface temperatures across the air gap.
Highest to lowest interest rate risk : Rank bonds I-V from highest to lowest interest rate risk (or effective duration):
Determine the rate of heat loss from the absorber plate : Flat-plate solar collectors are often tilted up toward the sun in order to intercept a greater amount of direct solar radiation.
Design and implement a program : CSP1150 - design and implement a program that allows the user to play a single-player dice game based loosely on the game Farkle
Describe which method you used to make your determination : Prepare a report (see below) using the numerical methods of descriptive statistics presented. Describe which method you used to make your determination.
Determine the fraction of heat transferred by radiation : A vertical 1.5-m-high and 3.0-m-wide enclosure consists of two surfaces separated by a 0.4-m air gap at atmospheric pressure.
Mortgage interest rate they offer you on your credit rating : Mortgage lenders base the mortgage interest rate they offer you on your credit rating.
Which one is smuckers trying to occupy : Of the five generic strategic positions, which one is Smuckers trying to occupy? Explain your answer. Provide details to back up your claim.

Reviews

len1617318

8/29/2017 1:31:11 AM

Here are some minor tips and notes regarding Assignment 1 based upon questions I've been asked and issues I've encountered in people's work. I'll post more as they emerge. ________________________________________ Avoid combining "roll the dice" (i.e. generating a list of random numbers between 1 and 6 based on how many dice remain) and "check for matches". Treat them as two separate things. Generate the entire list of rolled dice (and sort it), then check for matching dice. ________________________________________

len1617318

8/29/2017 1:30:45 AM

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

len1617318

8/29/2017 1:29:50 AM

Criteria Marks Pseudocode These marks are awarded for submitting pseudocode which suitably represents the design of your source code. Pseudocode will be assessed on the basis of whether it clearly describes the steps of the program in English, and whether the program is well structured. 5 Functionality These marks are awarded for submitting source code that implements the requirements specified in this brief, in Python 3. Code which is not functional or contains syntax errors will lose marks, as will failing to implement requirements as specified. 10 Code Quality These marks are awarded for submitting well-written source code that is efficient, well- formatted and demonstrates a solid understanding of the concepts involved. This includes appropriate use of commenting and adhering to best practise. 5 Total: 20

len1617318

8/29/2017 1:28:39 AM

Criteria Marks Pseudocode These marks are awarded for submitting pseudocode which suitably represents the design of your source code. Pseudocode will be assessed on the basis of whether it clearly describes the steps of the program in English, and whether the program is well structured. 5 Functionality These marks are awarded for submitting source code that implements the requirements specified in this brief, in Python 3. Code which is not functional or contains syntax errors will lose marks, as will failing to implement requirements as specified. 10 Code Quality These marks are awarded for submitting well-written source code that is efficient, well- formatted and demonstrates a solid understanding of the concepts involved. This includes appropriate use of commenting and adhering to best practise. 5 Total: 20

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd