-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28010.2041 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Juego Numero Secreto", "Juego Numero Secreto\Juego Numero Secreto.csproj", "{875D41EF-8591-462A-9F18-59FF7E0CDCEC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{875D41EF-8591-462A-9F18-59FF7E0CDCEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{875D41EF-8591-462A-9F18-59FF7E0CDCEC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{875D41EF-8591-462A-9F18-59FF7E0CDCEC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{875D41EF-8591-462A-9F18-59FF7E0CDCEC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6BD06FD6-3E6F-4F8A-A0AD-5425938B68DD} | ||
EndGlobalSection | ||
EndGlobal |
9 changes: 9 additions & 0 deletions
9
Juego Numero Secreto/Juego Numero Secreto/Juego Numero Secreto.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<RootNamespace>Juego_Numero_Secreto</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
|
||
namespace ConsoleApp10 | ||
{ | ||
class Program | ||
{ | ||
|
||
|
||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Bienvenidos al juego del número secreto"); | ||
Console.ReadKey(); | ||
Console.WriteLine("Tienes que adivinar el número que estoy pensando entre 1 y 20..."); | ||
Random generador = new Random(); | ||
int numSecreto = generador.Next(21); | ||
int intentos = 0; | ||
while (intentos == 0) | ||
{ | ||
Console.WriteLine("Primero elige la dificultad: 1 = fácil, 2 = mediana, 3 = difícil"); | ||
int diff = int.Parse(Console.ReadLine()); | ||
if (diff == 1) | ||
{ | ||
intentos = 10; | ||
} | ||
else if (diff == 2) | ||
{ | ||
intentos = 5; | ||
} | ||
else if (diff == 3) | ||
{ | ||
intentos = 3; | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Dificultad no válida, introduce otro valor"); | ||
} | ||
} | ||
Console.WriteLine("Dime que número crees que es"); | ||
int prueba = int.Parse(Console.ReadLine()); | ||
if (prueba == numSecreto) | ||
{ | ||
Console.WriteLine("Has acertado!!"); | ||
Console.WriteLine("Fin del juego!"); | ||
} | ||
else | ||
intentos--; | ||
{ | ||
while (intentos > 0 && prueba != numSecreto) | ||
{ | ||
intentos--; | ||
Console.WriteLine("Has fallado! Prueba otra vez"); | ||
prueba = int.Parse(Console.ReadLine()); | ||
if (prueba == numSecreto) | ||
{ | ||
Console.WriteLine("Has acertado!!"); | ||
Console.WriteLine("Fin del juego!"); | ||
} | ||
if (intentos == 0) | ||
{ | ||
Console.WriteLine("Te has quedado sin intentos"); | ||
Console.WriteLine("Fin del juego"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |