Advertisement
Guest User

Untitled

a guest
Aug 24th, 2023
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Runtime.CompilerServices;
  3.  
  4. namespace _04._Darts {
  5.   internal class Program {
  6.     static void Main(string[] args) {
  7.       string playerName = Console.ReadLine();
  8.       string input = Console.ReadLine();
  9.       double beginnerPoints = 301;
  10.       int success = 0;
  11.       int fail = 0;
  12.  
  13.       while (input != "Retire") {
  14.         int points = int.Parse(Console.ReadLine());
  15.         //if (beginnerPoints < 0)
  16.         //{
  17.         //    beginnerPoints = 1;
  18.         //}
  19.         //if (beginnerPoints >= points)
  20.         //{
  21.         //    success++;
  22.         //}
  23.         //else
  24.         //{
  25.         //    fail++;
  26.         //}
  27.         //if (input == "Single")
  28.         //{
  29.         //    beginnerPoints -= points;
  30.         //}
  31.         //else
  32.         if (input == "Double") {
  33.           points *= 2;
  34.           //beginnerPoints -= points;
  35.         } else if (input == "Triple") {
  36.           points *= 3;
  37.           //beginnerPoints -= points;
  38.         }
  39.  
  40.         if (beginnerPoints >= points) {
  41.           success++;
  42.           beginnerPoints -= points;
  43.         } else {
  44.           fail++;
  45.         }
  46.         if (beginnerPoints == 0 || beginnerPoints == -1) {
  47.           Console.WriteLine($"{playerName} won the leg with {success} shots.");
  48.           //break;
  49.           return;
  50.         }
  51.         input = Console.ReadLine();
  52.       }
  53.       //if (input == "Retire") {
  54.       Console.WriteLine($"{playerName} retired after {fail} unsuccessful shots.");
  55.       //}
  56.     }
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement