| 

.NET C# Java Javascript Exception

1
Ich würde gerne in diesen Code einbauen dass ich am Ende des Codes beide Scores der Spieler anzeigen lässt. Ist dies möglich?

// Visual Studio

using System;

namespace firstProject
{
class Program
{
static void Main(string[] args)
{
//Blackjack :)
string name;
string nameTwo;
Random dice = new Random();
int draw1 = dice.Next(1, 11);
int draw2 = dice.Next(1, 11);
int draw3 = dice.Next(1, 11);
int draw4 = dice.Next(1, 11);
int draw5 = dice.Next(1, 11);


int oneCard = (draw1);
int twoCards = (draw1 + draw2);
int threeCards = (draw1 + draw2 + draw3);
int fourCards = (draw1 + draw2 + draw3 + draw4);
int fiveCards = (draw1 + draw2 + draw3 + draw4 + draw5);
/* int finalScore1 = new int();
int finalScore2 = new int(); */
int player2Draw1 = dice.Next(1, 11);
int player2Draw2 = dice.Next(1, 11);
int player2Draw3 = dice.Next(1, 11);
int player2Draw4 = dice.Next(1, 11);
int player2Draw5 = dice.Next(1, 11);
int player2OneCard = (player2Draw1);
int player2TwoCards = (player2Draw1 + player2Draw2);
int player2ThreeCards = (player2Draw1 + player2Draw2 + player2Draw3);
int player2FourCards = (player2Draw1 + player2Draw2 + player2Draw3 + player2Draw4);
int player2FiveCards = (player2Draw1 + player2Draw2 + player2Draw3 + player2Draw4 + player2Draw5);
// player 1 name player2 name wenn nichtmehr ideeen)
// --------------------------------------------------------SPIELER 1 SPIEL START-------------------------------------------------------------------------------------------------
Console.WriteLine("Do you want to see the rules?");

if (Console.ReadLine() == "yes")
{
Console.WriteLine("Quick special rules:");
Console.WriteLine("You loose if:\n\r 1. Your score is more than 21. \n 2. Your enemy player is closer to 21");
Console.WriteLine("¬ If Player1 and Player2 lose, it would be a draw!");
Console.WriteLine(" ");
Console.WriteLine("To start the game Type: start");
Console.WriteLine("To take the next Card Type: next");
Console.WriteLine("If you like your score Press: ENTER");
Console.WriteLine(" ");
}
else
{
Console.WriteLine("Accepted");
Console.WriteLine(" ");
}
Console.WriteLine("Player1 Please enter Your name:");
name = Console.ReadLine();
Console.WriteLine("Player2 Please enter Your name:");
nameTwo = Console.ReadLine();
Console.WriteLine("Player1: " + name);
Console.WriteLine("Player2: " + nameTwo);
Console.WriteLine(" ");

Console.WriteLine("P1 Ready to Start?");
if (Console.ReadLine() == "start")
{
Console.WriteLine(draw1);


if (Console.ReadLine() == "next")
{
Console.WriteLine(draw2);
Console.WriteLine($"Your score is: {twoCards}");

if (Console.ReadLine() == "next")
{
Console.WriteLine(draw3);
Console.WriteLine($"Your score is: {threeCards}");

if (Console.ReadLine() == "next")
{
Console.WriteLine(draw4);
Console.WriteLine($"Your score is: {fourCards}");
if (Console.ReadLine() == "next")
{
Console.WriteLine(draw5);
Console.WriteLine($"Your score is: {fiveCards}");

if (fiveCards <= 21)
{
if (fiveCards == 21)
{
Console.WriteLine($"{name}'s Your score is: !21! perfect");
}
else
{
Console.WriteLine($"{name}'s score is: {fiveCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {name}'s score is: {fiveCards}");
}

}

else
{
if (fourCards <= 21)
{
if (fourCards == 21)
{
Console.WriteLine($"{name}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{name}'s score is: {fourCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {name}'s score is: {fourCards}");
}

}

}

else
{
if (threeCards <= 21)
{
if (threeCards == 21)
{
Console.WriteLine($"{name}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{name}'s score is: {threeCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. { name}'s score is: {threeCards}");
}

}
}

else
{
if (twoCards <= 21)
{
if (twoCards == 21)
{
Console.WriteLine($"{name}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{name}'s score is: {twoCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {name}'s score is: {twoCards}");
}
}

}
else
{
Console.WriteLine($" {name}'s score is: {oneCard}");
}

}
//------------------------------------------------------------ SPIELER 2 Selbes Spiel -----------------------------------------------------------------------------------
Console.WriteLine("P2 Ready to Start?");
if (Console.ReadLine() == "start")
{
Console.WriteLine(player2Draw1);


if (Console.ReadLine() == "next")
{
Console.WriteLine(player2Draw2);
Console.WriteLine($"Your score is: {player2TwoCards}");

if (Console.ReadLine() == "next")
{
Console.WriteLine(player2Draw3);
Console.WriteLine($"Your score is: {player2ThreeCards}");

if (Console.ReadLine() == "next")
{
Console.WriteLine(player2Draw4);
Console.WriteLine($"Your score is: {player2FourCards}");
if (Console.ReadLine() == "next")
{
Console.WriteLine(player2Draw5);
Console.WriteLine($"Your score is: {player2FiveCards}");

if (player2FiveCards <= 21)
{
if (player2FiveCards == 21)
{
Console.WriteLine($"{nameTwo}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{nameTwo}'s score is: {player2FiveCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {nameTwo}'s score is: {player2FiveCards}");
}

}

else
{
if (player2FourCards <= 21)
{
if (player2FourCards == 21)
{
Console.WriteLine($"{nameTwo}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{nameTwo}'s score is: {player2FourCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {nameTwo}'s score is: {player2FourCards}");
}

}

}

else
{
if (player2ThreeCards <= 21)
{
if (player2ThreeCards == 21)
{
Console.WriteLine($"{nameTwo}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{nameTwo}'s score is: {player2ThreeCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {nameTwo}'s score is: {player2ThreeCards}");
}

}
}

else
{
if (player2TwoCards <= 21)
{
if (player2TwoCards == 21)
{
Console.WriteLine($"{nameTwo}'s score is: !21! perfect");
}
else
{
Console.WriteLine($"{nameTwo}'s score is: {player2TwoCards} Good");
}

}
else
{
Console.WriteLine($"That looks very bad. {nameTwo}'s score is: {player2TwoCards}");
}
}

}
else
{
Console.WriteLine($" {nameTwo}'s score is {player2OneCard}");
}


}
if()


if(Console.ReadLine() == "end")
{
Console.WriteLine("The game has ended.");
}
else
{
Console.WriteLine("Try again ?");
}
//ENDE WER GEWONNEN?




}
}
}
News:
28.02.2020
TOP TECHNOLOGIES CONSULTING GmbH