USA: +1(715)227-4880, UK: +44-7896988486, AU:+61-452503850

# Assignment

Computing Skills Assignment Help

### CP1401 SP12018 Assessment1 Planning the Tropical Golf Game

Rating:

CP1401 SP12018 Assessment1 Planning the Tropical Golf Game

You are to plan a golf game program as outlined in the following description. Use what you have learned in class, including functions, selection and repetition. Assessment 2 will cover the implementation of this program in Python.

# Program Features:

Short description:

·         You are required to prepare a plan 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:

o   The ball starts 230m away from the hole

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

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

o   Once the ball is in the hole the player is told how many swings it tookand whether they are over or under par

o   When the player chooses to quit, the game  thanks the player by name and says goodbye

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.

(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>.
(replace <user name> with whatever the user entered…)

1. 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

2. 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:

o              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.

o        In your plan you can just say ‘generate x as a random number between 80 and 120’ for this. All languages have a way to do this and we will see Pythons in the near future.

The clubs and their average distances are:

o        Driver:          100m

o        Iron:              30m

o        Putter:           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.

o        Invalid club selection = air swing :( Your shot went 0m. You are 230m from the hole, after 1 shot/s

o        Note the similarities to the output from a successful swing (reuse?)

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 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.

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

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

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

# Planning:

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 golf game (e.g. a single swing could be implemented as a function). For each function you are to provide an IPO chart listing all variables which are needed for your solution. You should consult the lecture slides and your textbook for examples of IPO charts.In cases where selections are necessary you must include a suitable condition action table directly below the IPO chart.  Follow the sample solution provided as a guide.

You also need to providea detailed algorithm (pseudocode or flowchart) for each function that shows how the game would operate.

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.

# In this assignment, you will be focusing on basic planning using selections, repetition and functions.

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

Make use of named constants (named in all caps) where appropriate. You should be able to modify these constants to adjust the gameplay - including the average distances (one per club), the percentages, etc. This is one of the most important aspects of this assignment, so consider carefully how to use constants. Remember to use your constants everywhere you can.

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

# Submission:

Hand in one MS Word (.docx) or PDF (.pdf) file containing all of your planning.

Please name the file like: LastnameFirstnameA1.docx orLastnameFirstnameA1.pdf

e.g. if your name were Miles Davis, the filename would be DavisMilesA1.docx

Submit this file by uploading ittothe LearnJCU Assignment One Dropbox, found under Assessment.

# Due:

Submit your assignment bythe date and time specified on LearnJCU.

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

#### Details

• Number of views:
681
• PRICE :
AU\$ 220.00

### Our Top Experts

Holding a PhD degree in Finance, Dr. John Adams is experienced in assisting students who are in dire need...

55 - Completed Orders

Canada, Toronto I have acquired my degree from Campion College at the University of Regina Occuption/Desi...

52 - Completed Orders

Even since I was a student in Italy I had a passion for languages, in fact I love teaching Italian, and I...

102 - Completed Orders

To work with an organization where I can optimally utilize my knowledge and skills for meeting challenges...

109 - Completed Orders

JOB OBJECTIVE Seeking entry level assignments in Marketing & Business Development with an organization...

202 - Completed Orders

Current work profile Project manager- The Researchers Hub (2nd Jan 2016 to presently working) Researc...

20 - Completed Orders

Sales Assistant, Mito Marina Assigned to the Stationery dept – assisted in merchandising, stock taking...

100 - Completed Orders

Personal Profile Dedicated and highly experienced private chauffeur. High energy, hardworking, punctua...

200 - Completed Orders

I'm Lizzy, full time education specialist in English, Essay Writing, Economics and Maths. Having Assi...

109 - Completed Orders

HSC PREPARATION I specialise in English coaching programs for HSC students. My personalised and results-...

202 - Completed Orders