Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _43Tennis
- {
- class Program
- {
- static void Main(string[] args)
- {
- int scoreA = 0;
- int scoreB = 0;
- char invoer;
- bool gewonnen = false;
- do
- {
- Console.Write("Geef in of speler A of speler B gescoord heeft: ");
- invoer = char.Parse(Console.ReadLine().ToUpper());
- //kijken naar invoer --> speler a of speler b?
- //+ probleem 0, 15, 30, 40 oplossen (normaal sprongen van +15, laatste sprong is maar +10)
- if (invoer == 'A')
- {
- if (scoreA >=30)
- {
- scoreA = scoreA + 10;
- }
- else
- {
- scoreA = scoreA + 15;
- }
- }
- else
- {
- if (scoreB >= 30)
- {
- scoreB = scoreB + 10;
- }
- else
- {
- scoreB = scoreB + 15;
- }
- }
- //kijken of één van de twee spelers boven de 40 zitten en dus voordeel hebben
- //kijken of één van de spelers al dan niet gewonnen heeft
- if (scoreB>40 || scoreA>40)
- {
- if (Math.Abs(scoreA-scoreB)>10)
- {
- gewonnen = true;
- }
- else
- {
- if (scoreA > scoreB)
- {
- Console.WriteLine("Speler A heeft voordeel");
- }
- else if (scoreB > scoreA)
- {
- Console.WriteLine("Speler B heeft voordeel");
- }
- else
- {
- Console.WriteLine("Duce");
- }
- }
- }
- else
- {
- Console.WriteLine("De score van speler A is: " + scoreA);
- Console.WriteLine("De score van speler B is: " + scoreB);
- }
- } while (gewonnen == false);
- //resultaat tonen
- if (scoreA > scoreB)
- {
- Console.WriteLine("Speler A heeft een punt!");
- }
- else
- {
- Console.WriteLine("Speler B heeft een punt!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement