From 13980cf04a71d8c06980274437808dc3385031fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20F=C3=B6lker?= Date: Tue, 7 Jun 2022 19:42:03 +0200 Subject: [PATCH] Add project files. --- szoftverteszt.sln | 25 ++++++++ szoftverteszt/Program.cs | 99 ++++++++++++++++++++++++++++++ szoftverteszt/szoftverteszt.csproj | 8 +++ 3 files changed, 132 insertions(+) create mode 100644 szoftverteszt.sln create mode 100644 szoftverteszt/Program.cs create mode 100644 szoftverteszt/szoftverteszt.csproj diff --git a/szoftverteszt.sln b/szoftverteszt.sln new file mode 100644 index 0000000..0ddbc2a --- /dev/null +++ b/szoftverteszt.sln @@ -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 diff --git a/szoftverteszt/Program.cs b/szoftverteszt/Program.cs new file mode 100644 index 0000000..079671f --- /dev/null +++ b/szoftverteszt/Program.cs @@ -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(); + } + } +} diff --git a/szoftverteszt/szoftverteszt.csproj b/szoftverteszt/szoftverteszt.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/szoftverteszt/szoftverteszt.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + +