Advertisement
Valantina

Darts/EX

Jun 13th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Darts
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string playerName = Console.ReadLine();
  10.             int successfullCount = 0;
  11.             int unsucessfullCount = 0;
  12.             int totalPts = 301;
  13.             while (true)
  14.             {
  15.                 if (totalPts <= 0)
  16.                 {
  17.                     Console.WriteLine($"{playerName} won the leg with {successfullCount} shots.");
  18.                     return;
  19.                 }
  20.                 string side = Console.ReadLine();
  21.                 if (side == "Retire")
  22.                 {
  23.                     Console.WriteLine($"{playerName} retired after {unsucessfullCount} unsuccessful shots.");
  24.                     return;
  25.                 }
  26.                 int pts = int.Parse(Console.ReadLine());
  27.                 switch (side)
  28.                 {
  29.                     case "Double":
  30.                         {
  31.                             pts *= 2;
  32.                             break;
  33.                         }
  34.                     case "Triple":
  35.                         {
  36.                             pts *= 3;
  37.                             break;
  38.                         }
  39.                 }
  40.                 bool sucessfull = totalPts - pts >= 0;
  41.                 bool unsucessfull = totalPts - pts < 0;
  42.                 if (sucessfull)
  43.                 {
  44.                     successfullCount++;
  45.                     totalPts -= pts;
  46.                 }
  47.                 if (unsucessfull)
  48.                 {
  49.                     unsucessfullCount++;
  50.  
  51.                 }
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement