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

  What is the :: called in c++

What is the :: called in C++ when used like this std::endl; In my main file, what line of code prevents me from having to put std before every endl

  C++ code to find the greatest common divisor

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

  Provide a class diagram for every user authored class

Examine the sample code you have been provided with. This code is for a simple Car Hire management system. It contains a number of classes.

  Write an application that shows the sum

This is for Object-Oriented Programming Using C++ language - Edition Joyce Farrell. Please ensure to read everything that I have wrote so that there is no confusion.

  Gstring manipulation functions

Write a program that will define the followingstring manipulation functions. Each is analogous to the corresponding C++ string function.

  Create a class called card player and deck

Write a class called "Card" with the following traits: it holds two private variables, a suit and a value (ace is high). It has public functions that randomly generate and modify the suit, value and print out the suit/value to the screen. Write a ..

  Farey fractions of level one

Write a program that for a number n entered by the user creates-by constantly extending it-a linked list of fractions at level n and then displays them.

  Define the class bankaccount

Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder's name (string), account number (int), account type (string, checking/saving), balance (double),..

  Compare and contrast the object-oriented approach to design

compare and contrast the object-oriented approach to design and the traditional approach.do you believe that there are

  Pre and post increament and decrement operators

We are going to overload the following operators in the fract class- pre and post increament (++) and decrement (--) operators

  Need to convert this c code to mips

You need to convert this C code to MIPS - The subsequent is a sample output (user input is 2): Enter an integer: 2 The count of the integers that are greater than 2 is: 3 You have to assure the requirements specific in the instruction.

  Viewer features of the application

Sharon has started to use both the stock details management and the file information viewer features of the application. However, while using the file information viewer application, she accidentally enters the path of a folder that does not exist..

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