Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BasketBattle
- {
- static void Main()
- {
- // basket Battle
- //initializing variables and basic settings
- Console.WriteLine("Enter a name of the player that starts shooting first in first round");
- Console.Write("\"Simeon\" or \"Nakov\": ");
- string F = Console.ReadLine(); // F -> who shoot first round
- F = F.ToLower();
- Console.Write("\nNumber of rounds in the game: [1...20] ");
- int N = int.Parse(Console.ReadLine()); // N -> number of rounds
- Console.WriteLine();
- int roundCurrent = 0;
- double roundHalf = 0.0;
- int playerTurn; // 1 - Simeon, 2 - Nakov
- if (F == "simeon")
- {
- playerTurn = 1;
- }
- else
- {
- playerTurn = 2;
- }
- int P; // amounts of pts every player tries to score
- string I; // success or fail
- int player1Simeon = 0; // Simeon's actual pts
- int player2Nakov = 0; // Nakov's actual pts
- // real game
- do
- {
- Console.Write("Round {0}: ", roundCurrent+1);
- if (playerTurn == 1)
- {
- Console.WriteLine("Simeon's turn");
- }
- else
- {
- Console.WriteLine("Nakov's turn");
- }
- Console.Write("how many points: [1...500] ");
- P = int.Parse(Console.ReadLine());
- Console.Write("\nsuccess or fail: ");
- I = Console.ReadLine();
- Console.WriteLine();
- if (I == "success")
- {
- if (playerTurn == 1)
- {
- player1Simeon += P;
- if (player1Simeon > 500)
- {
- player1Simeon -= P;
- }
- }
- else
- {
- player2Nakov += P;
- if (player2Nakov > 500)
- {
- player2Nakov -= P;
- }
- }
- }
- roundHalf += 0.5;
- if (roundHalf == Math.Round(roundHalf))
- {
- roundCurrent++;
- }
- else
- {
- playerTurn = 3 - playerTurn;
- }
- }
- while ((roundCurrent < N) && (player1Simeon != 500) && (player2Nakov != 500));
- //printing the results: final score
- if (roundCurrent < N) // there is a winner
- {
- if (player1Simeon == 500)
- {
- Console.WriteLine("The winner is Simeon");
- Console.WriteLine("player won the game in {0} rounds", roundCurrent);
- Console.WriteLine("Nakov lost with {0} pts", player2Nakov);
- }
- else
- {
- Console.WriteLine("The winner is Nakov");
- Console.WriteLine("player won the game in {0} round", roundCurrent);
- Console.WriteLine("Simeon lost with {0} pts", player1Simeon);
- }
- }
- if ((roundCurrent == N) && (player1Simeon == player2Nakov))
- {
- Console.WriteLine("DRAW");
- Console.WriteLine("players have {0} pts", player1Simeon);
- }
- else
- {
- if (roundCurrent == N)
- {
- if (player1Simeon > player2Nakov)
- {
- Console.WriteLine("Simeon have more pts");
- Console.WriteLine("the difference between players is: {0} pts", player1Simeon - player2Nakov);
- }
- else
- {
- Console.WriteLine("Nakov have more pts");
- Console.WriteLine("the difference between players is: {0} pts", player2Nakov - player1Simeon);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement