Skip to content

Commit

Permalink
Merge pull request #1 from tothlevente/feature
Browse files Browse the repository at this point in the history
New pull request for number guesser
  • Loading branch information
tothlevente authored Jan 16, 2025
2 parents 57dbdf7 + 91677f0 commit 9016454
Show file tree
Hide file tree
Showing 30 changed files with 375 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "app.sln"
}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Number guesser 🎈

The computer thinks of a number and you try to guess it.

The program gives you feedback on whether you guessed a higher or lower number.

## Available scripts:

- `dotnet run`
- `dotnet build`
- `dotnet restore`

## Explanation:

1. **Random Number Generation**: A `Random` object is used to generate a random number between 1 and 100.
2. **User Guess**: The user's guess is read from the console.
3. **Feedback**: The program provides feedback on whether the guess is too high or too low.
4. **Loop**: The program continues looping until the user guesses the correct number.
5. **Attempt Counting**: The program counts the number of attempts the user makes to guess the number.

## License:

- This project is licensed under MIT.

For more information please visit the license files.
22 changes: 22 additions & 0 deletions app.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "app", "app\app.csproj", "{9371A2F9-55A0-4805-829F-72CEE16F4869}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9371A2F9-55A0-4805-829F-72CEE16F4869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9371A2F9-55A0-4805-829F-72CEE16F4869}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9371A2F9-55A0-4805-829F-72CEE16F4869}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9371A2F9-55A0-4805-829F-72CEE16F4869}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
52 changes: 52 additions & 0 deletions app/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;

namespace NumberGuessingGame
{
class Program
{
static void Main(string[] args)
{
Random random = new Random();
int secretNumber = random.Next(1, 101);
int guess = 0;
int attempts = 0;

Console.WriteLine("Guessing Game!");
Console.WriteLine("The computer has thought of a number between 1 and 100.");
Console.WriteLine("Try to guess it!");

while (guess != secretNumber)
{
Console.Write("Your guess: ");
string? input = Console.ReadLine();
if (input == null)
{
Console.WriteLine("Input cannot be null. Please enter a valid number.");
continue;
}

if (int.TryParse(input, out guess))
{
attempts++;

if (guess < secretNumber)
{
Console.WriteLine("The secret number is higher.");
}
else if (guess > secretNumber)
{
Console.WriteLine("The secret number is lower.");
}
else
{
Console.WriteLine($"Congratulations, you guessed the number in {attempts} attempts!");
}
}
else
{
Console.WriteLine("Please enter a valid number.");
}
}
}
}
}
10 changes: 10 additions & 0 deletions app/app.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Binary file added app/bin/Debug/net8.0/app
Binary file not shown.
23 changes: 23 additions & 0 deletions app/bin/Debug/net8.0/app.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"app/1.0.0": {
"runtime": {
"app.dll": {}
}
}
}
},
"libraries": {
"app/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file added app/bin/Debug/net8.0/app.dll
Binary file not shown.
Binary file added app/bin/Debug/net8.0/app.pdb
Binary file not shown.
12 changes: 12 additions & 0 deletions app/bin/Debug/net8.0/app.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
22 changes: 22 additions & 0 deletions app/obj/Debug/net8.0/app.AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("app")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+57dbdf7b7476830551b6537338073849e7a89bc1")]
[assembly: System.Reflection.AssemblyProductAttribute("app")]
[assembly: System.Reflection.AssemblyTitleAttribute("app")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

1 change: 1 addition & 0 deletions app/obj/Debug/net8.0/app.AssemblyInfoInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cf9fd0102ca120037bef1e562771a90a4291e3e5bc63a74979ba1367f1c02138
13 changes: 13 additions & 0 deletions app/obj/Debug/net8.0/app.GeneratedMSBuildEditorConfig.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = app
build_property.ProjectDir = /workspaces/number-guesser/app/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
8 changes: 8 additions & 0 deletions app/obj/Debug/net8.0/app.GlobalUsings.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file added app/obj/Debug/net8.0/app.assets.cache
Binary file not shown.
1 change: 1 addition & 0 deletions app/obj/Debug/net8.0/app.csproj.CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
35776f45ff1344387b33c0efd81175462921a7d415d110b5257f798329b739bc
15 changes: 15 additions & 0 deletions app/obj/Debug/net8.0/app.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/workspaces/number-guesser/app/bin/Debug/net8.0/app
/workspaces/number-guesser/app/bin/Debug/net8.0/app.deps.json
/workspaces/number-guesser/app/bin/Debug/net8.0/app.runtimeconfig.json
/workspaces/number-guesser/app/bin/Debug/net8.0/app.dll
/workspaces/number-guesser/app/bin/Debug/net8.0/app.pdb
/workspaces/number-guesser/app/obj/Debug/net8.0/app.GeneratedMSBuildEditorConfig.editorconfig
/workspaces/number-guesser/app/obj/Debug/net8.0/app.AssemblyInfoInputs.cache
/workspaces/number-guesser/app/obj/Debug/net8.0/app.AssemblyInfo.cs
/workspaces/number-guesser/app/obj/Debug/net8.0/app.csproj.CoreCompileInputs.cache
/workspaces/number-guesser/app/obj/Debug/net8.0/app.sourcelink.json
/workspaces/number-guesser/app/obj/Debug/net8.0/app.dll
/workspaces/number-guesser/app/obj/Debug/net8.0/refint/app.dll
/workspaces/number-guesser/app/obj/Debug/net8.0/app.pdb
/workspaces/number-guesser/app/obj/Debug/net8.0/app.genruntimeconfig.cache
/workspaces/number-guesser/app/obj/Debug/net8.0/ref/app.dll
Binary file added app/obj/Debug/net8.0/app.dll
Binary file not shown.
1 change: 1 addition & 0 deletions app/obj/Debug/net8.0/app.genruntimeconfig.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
748e14b28e37033efbf53b4ac04eeca7c0b56dcd4c8198fd460cc7f1f7803f17
Binary file added app/obj/Debug/net8.0/app.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions app/obj/Debug/net8.0/app.sourcelink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"/workspaces/number-guesser/*":"https://raw.githubusercontent.com/tothlevente/number-guesser/57dbdf7b7476830551b6537338073849e7a89bc1/*"}}
Binary file added app/obj/Debug/net8.0/apphost
Binary file not shown.
Binary file added app/obj/Debug/net8.0/ref/app.dll
Binary file not shown.
Binary file added app/obj/Debug/net8.0/refint/app.dll
Binary file not shown.
66 changes: 66 additions & 0 deletions app/obj/app.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"format": 1,
"restore": {
"/workspaces/number-guesser/app/app.csproj": {}
},
"projects": {
"/workspaces/number-guesser/app/app.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/workspaces/number-guesser/app/app.csproj",
"projectName": "app",
"projectPath": "/workspaces/number-guesser/app/app.csproj",
"packagesPath": "/home/codespace/.nuget/packages/",
"outputPath": "/workspaces/number-guesser/app/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/codespace/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/8.0.404/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}
15 changes: 15 additions & 0 deletions app/obj/app.csproj.nuget.g.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/codespace/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/codespace/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.11.1</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/codespace/.nuget/packages/" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions app/obj/app.csproj.nuget.g.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
71 changes: 71 additions & 0 deletions app/obj/project.assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"/home/codespace/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/workspaces/number-guesser/app/app.csproj",
"projectName": "app",
"projectPath": "/workspaces/number-guesser/app/app.csproj",
"packagesPath": "/home/codespace/.nuget/packages/",
"outputPath": "/workspaces/number-guesser/app/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/codespace/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/8.0.404/PortableRuntimeIdentifierGraph.json"
}
}
}
}
Loading

0 comments on commit 9016454

Please sign in to comment.