Advertisement
Valantina

DartsTournament/EX/27.07.2019

Jul 29th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P04_DartsTournament
  4. {
  5.     class P04_DartsTournament
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int startingPoints = int.Parse(Console.ReadLine());
  10.             int shotsCounter = 0;
  11.             bool wonWithBullseye = false;
  12.  
  13.             while (startingPoints > 0)
  14.             {
  15.                 string sector = Console.ReadLine();
  16.                 shotsCounter++;
  17.                 if ("bullseye" == sector)
  18.                 {
  19.                     wonWithBullseye = true;
  20.                     break;
  21.                 }
  22.                 int points = int.Parse(Console.ReadLine());
  23.  
  24.                 if ("number section" == sector)
  25.                 {
  26.                     startingPoints -= points;
  27.                 }
  28.                 else if ("double ring" == sector)
  29.                 {
  30.                     startingPoints -= (points * 2);
  31.                 }
  32.                 else if ("triple ring" == sector)
  33.                 {
  34.                     startingPoints -= (points * 3);
  35.                 }
  36.  
  37.                 if (startingPoints < 0)
  38.                 {
  39.                     break;
  40.                 }
  41.             }
  42.  
  43.             if (wonWithBullseye)
  44.             {
  45.                 Console.WriteLine($"Congratulations! You won the game with a bullseye in {shotsCounter} moves!");
  46.             }
  47.             else if (startingPoints == 0)
  48.             {
  49.                 Console.WriteLine($"Congratulations! You won the game in {shotsCounter} moves!");
  50.             }
  51.             else
  52.             {
  53.                 Console.WriteLine($"Sorry, you lost. Score difference: {Math.Abs(startingPoints)}.");
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement