Write function displayscorethat write score underneath

Assignment Help C/C++ Programming
Reference no: EM13976704

According to https://en.wikipedia.org/wiki/Target_archery, standard FITA targets are marked with 10 evenly spaced concentric rings, which have score values from 1 through 10 assigned to them. In FITA archery, targets are colored as follows:
• 1 ring & 2 ring - white
• 3 ring & 4 ring - black
• 5 ring & 6 ring - blue
• 7 ring & 8 ring - red
• 9 ring, 10 ring - gold

a. Write a function called target to draw an archery target using turtle graphics; target should have a parameter that determines the size of the drawing, and the center of the target should be at the origin (0, 0). To specify the colors of each ring, use a tuple:ringColors = ("white", "white", "black", "black", "blue", "blue", "red", "red", "yellow", "yellow"). After creating this tuple, just set the fill color of each ring before you draw it. You can use turtle.fillcolor() to set the color, and then turtle.begin_fill() and turtle.end_fill() to actually fill the shapes with a particular color.

b. Write a function shoot that simulates firing an arrow towards the target. The effect of shoot should be to indicate visually where on the target (or near the target) the "arrow" lands. You can use turtle.dot() for this. The landing position should be at a pseudo-random position on or near the target. Look at the documentation for the Python module random and choose a suitable function to help you generate a pseudo-random position. To use turtle.dot(), you will need a random number for both the x-coordinate and the y-coordinate, so generate two random numbers for one dot. The return value of shoot should be the distance between the origin and the point at which the arrow lands. You can use turtle.distance() for this.

c. Write a function score, which takes as parameters the distance of an arrow from the origin, and the radius of the target, and calculates the score for that arrow, according to the above instructions. I.e., 10 points for the inner most circle, then 9 points for the next circle, etc., out to 1 point for the outer most circle, and zero for missing the target. You may need to use some of the functions in the math module. The return value of score should be the calculated score.

d. Write a function displayScorethat writes a score underneath the target. Give it suitable parameters. You can use turtle.write() to display information on the turtle canvas.

e. Complete your program for playing three-shot archery by writing the function threeShots that draws the target (by calling target), shootsthree arrows(by calling shoot and score three times), adds up the scores for all three arrows, and then displays the total score using the function displayScore. Naturally, threeShots should use the other functions that you have already defined. Give threeShots any necessary parameters.

f. Restrictions: Do not use any global variables. Global variables are declared outside of any function, so all variables for this assignment must be declared inside of one of the functions. Use parameters and return values to share information between functions.

g. Give your assignment an appropriate name (hw4LastName.py), and upload it to the dropbox like normal.

Reference no: EM13976704

Questions Cloud

Find the occupation and the score of each player : We saw in class how to represent a binary search tree in Prolog. Write a predicate lca (K1, K2, T) which allows one to find the smallest common ancestor of K1 and K2 in the tree T. The predicate lca shall print the subtree T such that the root is ..
Souvenir sheets cost the postal service : The postal service of St. Lucia, an island in the West Indies, obtains a significant portion of its revenues from sales of special souvenir sheets to stamp collectors.
Complete the pension work sheet : Using the above information for Marlin Corporation, complete the pension work sheet for 2015.
How much work does it take to bring them together : Two point charges Q1 = 3.9 μC and Q2 = 7.7 μC are initially very far apart. They are then brought together, with a final separation of 2.4 m. How much work does it take to bring them together?
Write function displayscorethat write score underneath : Write a function displayScorethat writes a score underneath the target. Give it suitable parameters. You can use turtle.write() to display information on the turtle canvas.
Issued stock dividends during the current period : For this discussion, assume the role of an investor. How would you know whether the company you are considering to invest in has repurchased any of its own stock and/or issued stock dividends during the current period? Why is this important, and woul..
FIFO-LIFO and weighted average methods : Net income results, reported in the financial statement presentation, can be affected by the inventory reporting methods used. FIFO, LIFO, and weighted average methods each have their own implications during periods of inflation and deflation. Consid..
Calculate the rate at which firm can grow without changing : Calculate the rate at which a firm can grow without changing its leverage if its payout ratio is 75%, equity outstanding at the beginning of the year is $970,000, and its net income for the year is $157,000. What is the WACC for a firm with 45% debt ..
Description of quantitative methods : Description of quantitative method(s). Justify why you utilized this statistical method for your study. Analysis of the data (Discuss your results and include a separate sheet that shows your quantitative results in tabular or graphical form)

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Find the retail price for each product

Your program should use a switch statement to find the retail price for each product - Use a sentinel-controlled loop to decide when the program should stop looping and show the final output.

  Define a class that consists of three objects

Define a class that consists of three objects: day, month, and year. Within this class define two member function (constructor ) to initialize the objects to today?s date and one that display the date as follows: 05/7/2002

  Prepare a c program that has this description

n is an integer, >= 0. x points to the first element of an int array with n position. p points to the first element of another int array array, also with n position.

  What is the size of the hash table

What is the size of the hash table?What are hFint256() (16) and hFint256() (257)?

  Improvemented program

What does this program do and would you improve it?

  Why can not the this pointer be used in nonmember functions

Why can't the this pointer be used in nonmember functions? Why should the overloaded assignment operator return *this? What does *this always refer to? How is the operator keyword used?

  Write a function that moves the largest item

Write a function that moves the largest item on a given linked list to be the final node on the list

  Throws an exception from a deeply nested

Write a program that throws an exception from a deeply nested function and still has the catch handler following the try block enclosing the initial call in main catch the exception

  Explain the tree traversals in all orders

If the node 30 is deleted, the erase algorithm selects which node as the replacement node?

  Find the average of four 16-bit unsigned integers

Write a program (starting at address $4000) to find the average of four 16-bit unsigned integers stored at locations $5000, $5002, $5004 and $5006 and store the 16-bit result at location $5010.

  Create a program that displays the number of days

Create a program that displays the number of days in a month. Use a 12-element one-dimensional array to store the number of days in each month

  C++ code to find the greatest common divisor

C++ Code to find the Greatest common divisor between two numbers.

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