Add project files.
This commit is contained in:
99
szoftverteszt/Program.cs
Normal file
99
szoftverteszt/Program.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
szoftverteszt/szoftverteszt.csproj
Normal file
8
szoftverteszt/szoftverteszt.csproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user