Add project files.

This commit is contained in:
Csaba Fölker 2022-06-07 19:42:03 +02:00
parent d32cd540f6
commit 13980cf04a
3 changed files with 132 additions and 0 deletions

25
szoftverteszt.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "szoftverteszt", "szoftverteszt\szoftverteszt.csproj", "{FB79B184-60F9-4628-9F8B-AED6D1C0A292}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FB79B184-60F9-4628-9F8B-AED6D1C0A292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB79B184-60F9-4628-9F8B-AED6D1C0A292}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB79B184-60F9-4628-9F8B-AED6D1C0A292}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB79B184-60F9-4628-9F8B-AED6D1C0A292}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9120FF00-D829-4510-881D-621E4173F6A6}
EndGlobalSection
EndGlobal

99
szoftverteszt/Program.cs Normal file
View File

@ -0,0 +1,99 @@
using System;
using System.IO;
namespace szoftverteszt
{
class Program
{
static int beszam = 0;
static int veletlen = 0;
static int proba = 0;
static void Main(string[] args)
{
beker();
ertekel();
veletlen = general(1,beszam+1);
// Console.WriteLine(general(100, 500));
// Console.Write("Szám: {0}", veletlen);
talalgat();
fajlba();
Console.WriteLine("Vége. Nyomjon billentyűt!");
Console.ReadKey();
}
static void beker() {
Console.Write("Kérek egy számot: ");
try
{
beszam = int.Parse(Console.ReadLine());
if (beszam <= 0)
{
throw new Exception("Csak pozitív szám lehet!");
}
/* if (beszam <= 10) {
throw new Exception("Másod hiba");
}
*/
}
catch (Exception hiba) {
Console.WriteLine("Nem megfelelő szám.");
Console.WriteLine("Hiba szövege: {0}", hiba.Message);
}
}
static void ertekel() {
if (beszam > 0)
{
Console.WriteLine("Köszönöm, a számod: {0}", beszam);
}
}
static int general(int min, int max) {
Random rnd = new Random();
return rnd.Next(min,max);
}
static void talalgat() {
int betalal = 0;
do
{
try
{
Console.Write("Kérem a tipped: ");
betalal = int.Parse(Console.ReadLine());
proba++;
}
catch (Exception hiba)
{
Console.WriteLine("Csak 1-{0} közötti szám fogadható el!", beszam);
}
finally
{
if (veletlen < betalal)
{
Console.WriteLine("Az én számom kisebb.");
}
else if (veletlen > betalal)
{
Console.WriteLine("Az én számom nagyobb.");
}
else if (veletlen == betalal) {
Console.WriteLine("Gratulálok, kitaláltad {0} próbálkozásból!",proba);
}
}
if (betalal == 0)
{
break;
}
} while (veletlen!=betalal);
Console.WriteLine("Köszönöm, hogy játszottál.");
}
static void fajlba() {
StreamWriter egyfajl = new StreamWriter("pontok.txt",true);
egyfajl.WriteLine("{0}:{1}",proba,beszam);
egyfajl.Close();
}
}
}

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>