码迷,mamicode.com
首页 > 编程语言 > 详细

代写Python Golf Game 作业、代写Python Golf Game 作业

时间:2018-04-24 21:54:27      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:top   led   stand   selection   under   ace   letters   博士生   web编程   

Implementing the Tropical Golf Game

Task

You are to implement a golf game program as outlined in the following description. Use what you have created for Assignment One, making any changes or improvements

Program Features:

Short description:

?You are required to create a Python 3 program for a game of Tropical Golf. The player will be attempting to get the ball in the hole using the least amount of swings.

 

?The rules and gameplay for the program are as follows:

oThe game asks for the players name, and then welcomes the player and displays the menu

oThe main menu displays 3 options “Instructions”, “Play game and quit”

oIf the player chooses “I” the instructions are displayed

oIf the player chooses “P” the game is played:

?The ball starts 230m away from the hole

?The player chooses one of three clubs, each of which hits a different average distance

?Every hit travels directly towards the hole in a straight line (this is a simple golf game, we’re only playing in 2D)

?Once the ball is in the hole the player is told how many swings it took and whether 0they are over or under par

?‘Par’ is the estimate of how many swings a game should take. Par for this game is 5.

?The player may use as many swings as is necessary to get the ball in the hole

oAfter every menu choice OTHER than ‘Q’ the menu is displayed again.

oOnce the player enters “Q” the game thanks the player by name and says goodbye

?Additional Functionality

oYour main function is to maintain a list of past scores

?This list should be created empty before the menu is displayed

oOnce the game has been played the users score (total number of shots taken) will be returned, and appended to the list.

oWhen the user quits you will display a list of past scores, using the example below as a guide for your formatting

If the list of scores was [5,8,2,4,7,5] then the output would be

?附加功能

o您的主要功能是保留过去分数的列表

?在显示菜单之前,应该将此列表创建为空

o一旦游戏玩过,用户得分(拍摄总数)将被返回,并附加到列表中。

o当用户退出时,您将显示过去分数的列表,使用下面的示例作为格式化指南

如果分数列表是[5,8,2,4,7,5],那么输出就是

Round 1 : 5 shots. On par.

Round 2 : 8 shots. 3 over par.

Round 3 : 2 shots. 3 under par.

Round 4 : 4 shots. 1 under par.

Round 5 : 7 shots. 2 over par.

Round 6 : 5 shots. On par.?

Detailed instructions:

Ensure that your program has the following features:

 

1.Ask the player’s name and welcome them to the game using their name.

 

2.Show the game menu:

(I)nstructions

(P)lay golf

(Q)uit

 

The user will enter the first letter of each option to choose it.

 

3.If the user chooses (I) then the following message is to be displayed:|

 

This is a simple golf game in which each hole is 230m game away with par 5. You are able to choose from 3 clubs, the Driver, Iron or Putter. The Driver will hit around 100m, the Iron around 30m and the Putter around 10m. The putter is best used very close to the hole.

 

After the instructions are displayed the game menu will be presented again.

 

 

4.If the player chooses (Q) then the following message is to be displayed:

Farewell and thanks for playing <user name>.

 

5.After displaying the instructions, or playing a round of golf, the program is to return to the menu and loop until the user chooses to quit

 

6.If the user chooses (P) then a game of golf will begin as described below

 

Playing the game:

?The player starts 230m from the hole

 

?For each swing, the player chooses a club and then the program generates the distance hit for each shot, updating the distance to the hole accordingly. After each swing the distance the ball travelled, and the distance remaining is displayed along with the current score using something like:

Your shot went 103m. You are 127m from the hole, after 1 shot/s.

 

?The player has three clubs to choose from for each shot. Each club hits the ball a set average distance, but the actual distance randomly varies between 80% and 120% of the average. You will need to generate a random number between 80 and 120 to do this.

 

?The clubs and their average distances are:

oDriver:  100m (actual distance will be a random number between 80 and 120)

oIron: 30m

oPutter:  10m*

*When the ball is inside 10m and the putter is used, the shot will be between 80% and 120% of the distance to the hole, not the club’s average distance. The minimum distance the putter can hit is 1m (no 0m hits). All distances are whole numbers.

 

?The user will enter the first letter of a club to choose it (i.e. ‘I’ or ‘i’ for the Iron)

 

?If an invalid club is chosen, this is counted as an air swing (missed the ball) and the number of shots increases by one, but the ball doesn’t move.

 

Invalid club selection = air swing :(

Your shot went 0m. You are 230m from the hole, after 1 shot/s

 

oNote the similarities to the output from a successful swing

 

?The ball cannot be a negative distance to the hole. Whether it is in front of or behind the hole, it is still a positive distance to the hole. Most programming languages (including Python) have an absolute value function that you can use to help with this.

 

?Play proceeds until the ball is in the hole (distance to the hole is zero), and then the program informs the user of their score.

 

?The players score is the number of shots taken to get the ball in the hole. The final output will display the number of shots taken and how this relates to par. If their score is less than 5 (par for this hole) is “under par”, equal to 5 is called “par”, and more than 5 is “over par”. See sample output for exact outputs.

oClunk... After 10 hits, the ball is in the hole! Disappointing. You are 5 over par.

oClunk... After 5 hits, the ball is in the hole! And that’s par.

oClunk... After 3 hits, the ball is in the hole! Congratulations, you are 2 under par.

 

?If the player has done a previous round (i.e. this is the second time the game is played), the game should then display the total score with an appropriate message, and then show the game menu again.

 

?

Implementation:

Python file:

You are to divide your solution into functions, following the principles shown in class. These may involve one for each menu option (other than Quit) as well as functions for parts of the program (e.g.  calculating the current player balance could be implemented as a function).

 

Planning document:

You also need to provide an updated version of your previous planning document (NOT including your Flowgorithm file) showing an algorithm in pseudocode for each function, being sure to clearly indicate input and output variables for each. This should be based on your submission for Assignment One, with appropriate changes being made for new functionality.

 

You may show your assignment to your tutor during practical time to get comments or suggestions. It is important to note that you can only get help from staff in practical time after your prac work is finished.

 

General Principles:

In this assignment, you will be focusing on basic planning and implementation using selections, repetition, and functions. Lists may be used where they are feasible.

 

Use the techniques and patterns that you have learned and seen demonstrated in class.  

 

?You are allowed to use the code that Flowgorithm generates as a base for your project, although you will need to make additions to it:

oFlowgorithm does not create a main function, so you must do this at either the top or the bottom of your code

oFlowgorithm generated code does not always follow the best practices we have shown in lectures and pracs. Ensure that you do.

 

?Coding standards:

oVariables:

?Wherever possible, variables should be set at the top of the function

?Although Python does not use constants you may set variables to values that will remain the same for the life of the program. These should be named in all caps

?You should be able to modify these variables to adjust the various values of items such as PAR, STARTING_DISTANCE, etc. This is an important aspect of this assignment, so consider carefully how to use constants. Remember to use these variables everywhere you can.

?You will need to decide the best position to place these variables.

?You should AVOID the use of global variables unless they are needed in multiple places in the application

?In other words, you should pass the values to any functions that need them and any constants only needed in one function should be ONLY in that function

oIdentifier Names

?Variables should be named appropriately using either camelCase or under_scores

?No variables should be a single character such as “x” or “y” unless they are used in a loop as an index. Variable names should be meaningful, and describe their use and/or purpose

?Any list variable should be named with plurals to show multiple data is held (e.g. prices versus price)

?Function names should begin with a verb (they are active), for example getValue() is better than value(). Good verbs include – ‘get’, ‘display’, ‘calculate’, ‘check’ etc (not all these are good for this problem...)

oComments:

?You will need to add at LEAST one comment for each function that you define including main

?The comment should either be placed directly above or below the function header

?The comment should describe: (a) the purpose of the function, (b) any inputs and (c) any returned values

?Additional comments should be placed at any position where the functionality of the program may be unclear

?All code MUST be properly indented

oError handling:

?Note that menu choice and other character selection should handle upper and lower case letters.

?Look into the upper() or lower() functions in Python

?You also must make sure that any functions that get input from the user do error checking to ensure that the input is within the expected range (greater than zero, etc).

 

oOutput

?Make your output display as close as possible to the given examples, especially formatting and layout.

?Use Google to find out how to display tabs and other special characters using Python 3, or how to display things at a set width

 

oPython Functions

?Check out https://docs.python.org/3/ and look up:

?‘randint’ to see how to generate a random number in Python

?‘abs’ to see how to use Pythons absolute value function

?‘upper’ or ‘lower’ to see case conversion functions

 

Submission:

Hand in one Python 3 (.py) file containing your code

Please name the file like: FirstnameLastnameA2.py

e.g. if your name were Miles Davis, the filename would be MilesDavisA1.py

Submit your file by uploading it on LearnJCU under Assessment.

 

Due:

Submit your assignment by the date and time specified on LearnJCU.

Submissions received after this date will incur late penalties as described in the subject outline.

 

Integrity:

The work you submit for this assignment must be your own. You are allowed to discuss the assignment with other students and get assistance from your peers, but you may not do anyone else’s work for them and you may not get anyone else to do any part of your work. A good rule to follow when offering assistance is that you can describe how code works but you should not be giving code to others. Programs that are detected to be too similar to another student’s work will be dealt with promptly according to University procedures for handling plagiarism.

 

If you require assistance with the assignment, please ask general questions on the Slack site for it@jcu (see subject outline for details), or get specific assistance with your own work by talking with your lecturer or tutor.

 

NB: A quick note about planning and seeking assistance:

 

You should plan to start your assessment no less than two - three weeks before the due date. As you become more proficient with coding this length of time will shorten, but in the beginning stages you will need time to become accustomed to “thinking like a programmer”.

 

Planning ahead will allow you time to seek assistance with parts that may be confusing to you. You will not know what these items are until you start to complete the assessment.

 

Marking Scheme:

Rubric Two – Assignment Implementation

CriteriaExcellent

100Sound

80Basic

60Limited

40Unacceptable

0Weighting

Correct use of Python syntax No more than 3 errors in code syntax. More than 3 but no more than 5 errors in code syntax More than 5, but no more than 7 errors in code syntax.More than 7 but not more than 9 errors in code syntax.No code submitted, or more than 9 errors in code syntax.20

Correct use of Python comments Most comments are correctly inserted and clear, and no more than 3 comments are not. Most comments are correctly inserted and clear. More than 3 but no more than 5 comments are not. Some comments are correctly inserted and clear, but most comments are not.All comments are incorrectly inserted, or unclear and meaningless.No comments.10

Effective and correct use of variables in the implemented solution Most variables are correctly created and used, no more than 3 are not. No inappropriate use of global or constant variables. Most variables are correctly created and used, more than 3, but no more than 5, are not. No inappropriate use of global or constant variables. Most variables are correctly created and used, no more than 5 are not.Some variables are correctly created and used, but most are not.All variables are inconsistently used.30

Effective and correct use of functions in the implemented solution Most functions are correctly set up, and there are no more than 3 mistakes in inputs, outputs or use. Most functions are correctly set up, there are more than 3, but no more than 5, mistakes in inputs, outputs or use. Most functions are correctly set up, but there are more than 5 mistakes in inputs, outputs or use.Some functions are correctly used and set up, but most are not.No functions used, or all or incorrectly set up.10

Effective and correct use of conditionals in the implemented solution. Mostly correct use of conditional programming structures, no more than 3 mistakes in design or implementation. Mostly correct use of conditional programming structures, more than 3 but no more than 5 mistakes in design or implementation. Mostly correct use of conditional programming structures, more than 5 mistakes in design or implementation.Mostly incorrect use of conditionals, or most conditionals do not work as required.No use, or completely incorrect use of conditional structures.15

Effective and correct use of loops in the implemented solution. Mostly correct use of loop programming structures, no more than 3 mistakes in design or implementation.Mostly correct use of loop programming structures, more than more than 3 but no more than 5 mistakes in design or implementation.Mostly correct use of loop programming structures, more than 5 mistakes in design or implementation.Mostly incorrect use of loops or most conditionals do not work as required.No use, or completely incorrect use of loop structures.15

 

Example of game play. Game output is in Bold.  

 

What is your name?

Bob Welcome Bob.

Let‘s play golf, CP1401 style!

 

(I)nstructions

(P)lay round

(Q)uit

 

 

Invalid menu choice.

 

Let‘s play golf, CP1401 style!

 

Golf!

(I)nstructions

(P)lay round

(Q)uit

I

 

 

本团队核心人员组成主要包括硅谷工程师、BAT一线工程师,国内Top5硕士、博士生,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。

 

我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全  汇编语言 硬件编程 软件设计 工程标准规等。其中代写代做编程语言或工具包括但不限于以下范围:

C/C++/C#代写

Java代写

IT代写

Python代写

辅导编程作业

Matlab代写

Haskell代写

Processing代写

Linux环境搭建

Rust代写

Data Structure Assginment 数据结构代写

MIPS代写

Machine Learning 作业 代写

Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导

Web开发、网站开发、网站作业

ASP.NET网站开发

Finance Insurace Statistics统计、回归、迭代

Prolog代写

Computer Computational method代做

 http://www.6daixie.com/contents/3/1299.html

 

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

微信:codinghelp

This is a simple golf game in which each hole is 230m game away with par 5. You are able to choose from 3 clubs, the Driver, Iron or Putter. The Driver will hit around 100m, the Iron around 30m and the Putter around 10m. The putter is best used very close to the hole.

 

For each shot, you may use a driver, iron or a putter – each shot will vary in distance.

The average distance each club can hit is:

     Driver = 100m

     Iron = 30m

     Putter = 10m

Golf!

(I)nstructions

(P)lay round

(Q)uit

代写Python Golf Game 作业、代写Python Golf Game 作业

标签:top   led   stand   selection   under   ace   letters   博士生   web编程   

原文地址:https://www.cnblogs.com/helpcode/p/8933483.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!