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

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 [email protected] (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 或邮箱:[email protected]

微信: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

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

时间: 2024-11-05 15:48:26

代写Python Golf Game 作业、代写Python Golf Game 作业的相关文章

Python代写,Python作业代写,代写Python,代做Python(微信leechanx)

Python代写,Python作业代写,代写Python,代做Python(微信leechanx) Redis:Cannot assign requested address的解决办法 客户端频繁的连服务器,由于每次连接都在很短的时间内结束,导致很多的TIME_WAIT,以至于用光了可用的端口号,所以新的连接没办法绑定端口,即"Cannot assign requestedaddress".是客户端的问题不是服务器端的问题.通过netstat,的确看到很多TIME_WAIT状态的连接.

代写Python、代做Python、Python作业代写、Python代写(微信leechanx)

代写Python.代做Python.Python作业代写.Python代写(微信leechanx) i++ VS ++i性能区别 i++ 为 function () { tmp = i; i = tmp + 1; return tmp; } ++i 为 function () { i = i + 1; return i; }

Python代写,Python作业代写,代写Python,代做Python

Python代写,Python作业代写,代写Python,代做Python 我是一线IT企业程序员,目前接各种代码代写业务: 代写C语言.代做C语言.C语言作业代写.C语言代写 代写C++.代做C++.C++作业代写.C++作业代写 代写Python.代做Python.Python作业代写.Python作业代做 代写Java.代做Java.Java作业代写.Java作业代做 代写编程作业.代做编程.编程代写.编程代做 先写代码再给钱,不要任何定金!价钱公道,具体见图,诚信第一!(涉及图形化界面.

Python聚类分析作业代写代做、人工智能Python作业代写

分析要求: 1. 对所给463条评语进行分词聚类,分析其所反映的活动类型 以下是人工分析得出的主要活动类型的参考举例: 2. 按年份统计各种活动类型每年所提及的频次 比如:亲子阅览,这一活动在13年-17年每年分别有多少条评语提到过.对所有活动进行分析,提供结果列表. 3.提供过程源码 "十月一去的那个人呀!人山人海但是书比人多没毛病,一共有五六楼记不清楚了,特别大,进门需要过安检比地铁火车都要严格的!自习室特别有感觉耶,我们去就和观光一样不是去看书,是去看景的哈哈哈哈? 因为第一次去不太清楚大

C++代写,C++作业代写,代写C++,编程代写(微信leechanx)

C++代写,C++作业代写,代写C++,编程代写(微信leechanx) 主要的GC算法 三种基本方法:标记清除法.复制收集法.引用计数法 高级方法:分代回收法 一.标记清除法 标记阶段:先从根对象开始,以深度遍历的方式对其可达的对象(A可达对象B的意思是:A引用了B)标记,表明这些对象是存活的: 清除阶段:对未标注的对象进行空间回收,同时将所有已标记的对象清理标记状态,为下次标记做准备. 大致过程: 内存空间状态: 缺点: (1)标记-清除算法的比较大的缺点就是垃圾收集后有可能会造成大量的内存

C语言代写,C语言作业代写,代写C语言,C语言编程代写

C语言代写,C语言作业代写,代写C语言,C语言编程代写 我是一线IT企业程序员,目前接各种代码代写业务: 代写C语言.代做C语言.C语言作业代写.C语言代写 代写C++.代做C++.C++作业代写.C++作业代写 代写Python.代做Python.Python作业代写.Python作业代做 代写Java.代做Java.Java作业代写.Java作业代做 代写编程作业.代做编程.编程代写.编程代做 先写代码再给钱,不要任何定金!价钱公道,具体见图,诚信第一!(涉及图形化界面.或领域类知识如金融数

代写C语言,C语言代写,C语言作业代写,C语言编程代写

代写C语言,C语言代写,C语言作业代写,C语言编程代写 我是一线IT企业程序员,目前接各种代码代写业务: 代写C语言.代做C语言.C语言作业代写.C语言代写 代写C++.代做C++.C++作业代写.C++作业代写 代写Python.代做Python.Python作业代写.Python作业代做 代写Java.代做Java.Java作业代写.Java作业代做 代写编程作业.代做编程.编程代写.编程代做 先写代码再给钱,不要任何定金!价钱公道,具体见图,诚信第一!(涉及图形化界面.或领域类知识如金融数

R编程作业代写| 代写R编程分类作业|代写R作业|代做R语言作业

第一部分:关于表内的A.B方案的介绍:在研究第0-24周期间,课题方案为动态方案. 入组时若HBeAg>60 S/CO,给予A药物,即调肝益脾颗粒+恩替卡韦安慰剂(方案A),之后每4周进行一次检查,决定之后的治疗方案(见第二部分) 入组时若HBeAg<60 S/CO,给予B药物,即调肝健脾解毒颗粒+恩替卡韦(方案B),直至第24周结束. 第二部分:药物方案的动态转换 对于入组后应用A方案的患者,在前24周内,每4周进行一次含有ALT的肝功能检查和含有HBeAg的乙肝五项检查,根据指标进行药物转

代写java binary search trees|代写Java Data Structures CS作业|代写Java作业|Java 编程作业代写|Java作业代写

CS2230 Computer Science II: Data Structures Homework 7 Implementing Sets with binary search trees 30 points Goals for this assignment ? Learn about the implementation of Sets using binary search trees, both unbalanced and balanced ? Implement methods

B-Tree作业代写、代写C++B-Tree编程作业、C++程序设计代写代做帮做有偿代做

B-Tree作业代写.代写C++B-Tree编程作业Developed by Jerry Cain of Stanford University and adapted by Jingling Xue.We've learned that C++ considers the preservation of type information to be much moreimpor-tant than C ever does. With that understanding, C++'s supp