Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DartsGame
- {
- public static class Darts
- {
- /// <summary>
- /// Calculates the earned points in a single toss of a Darts game.
- /// </summary>
- /// <param name="x">x-coordinate of dart.</param>
- /// <param name="y">y-coordinate of dart.</param>
- /// <returns>The earned points.</returns>
- public static int GetScore(double x, double y)
- {
- if ((x * x) + (y * y) <= 1)
- {
- return 10;
- }
- else if ((x * x) + (y * y) <= 5 * 5)
- {
- return 5;
- }
- else if ((x * x) + (y * y) <= 10 * 10)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement