Advertisement
yahorrr

Untitled

Feb 9th, 2022
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DartsGame
  4. {
  5.     public static class Darts
  6.     {
  7.         /// <summary>
  8.         /// Calculates the earned points in a single toss of a Darts game.
  9.         /// </summary>
  10.         /// <param name="x">x-coordinate of dart.</param>
  11.         /// <param name="y">y-coordinate of dart.</param>
  12.         /// <returns>The earned points.</returns>
  13.         public static int GetScore(double x, double y)
  14.         {
  15.             if ((x * x) + (y * y) <= 1)
  16.             {
  17.                 return 10;
  18.             }
  19.             else if ((x * x) + (y * y) <= 5 * 5)
  20.             {
  21.                 return 5;
  22.             }
  23.             else if ((x * x) + (y * y) <= 10 * 10)
  24.             {
  25.                 return 1;
  26.             }
  27.             else
  28.             {
  29.                 return 0;
  30.             }
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement