keszverzio Verzio 1

This commit is contained in:
tothgergo
2026-09-15 12:53:49 +02:00
parent b729be9087
commit 7b28895b2c
6 changed files with 126 additions and 17 deletions

View File

@@ -1,3 +1,3 @@
<Solution>
<Project Path="SzimulaciOOP/SzimulaciOOP.csproj" />
<Project Path="SzimulaciOOP/SzimulaciOOP.csproj" Id="06316ff2-4bf8-4939-aa6c-2ac720137ae0" />
</Solution>

View File

@@ -10,6 +10,13 @@ namespace SzimulaciOOP
{
static void Main(string[] args)
{
fonok Főni = new fonok();
Főni.megindit("Alfa Romeo",200,35);
Főni.megindit("Fiat",1500,40);
Főni.megindit("Audi",500,80);
Főni.megindit("Lada",300,45);
Főni.megindit("Dacia",400,40);
}
}
}

View File

@@ -44,6 +44,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="auto.cs" />
<Compile Include="benzinkut.cs" />
<Compile Include="fonok.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -11,31 +11,41 @@ namespace SzimulaciOOP
{
public string nev;
public int soforpenze;
public double soforpenze;
public double fogyasztas;
public double benzin;
public double benzinkapacitas;
public double benzinKapacitas;
public double megteendoUt;
public double hianyzoBenzin;
/*
soforpenze,autofogyasztasa,benzin,benzintankméret(30-200),adotthosszusaguut
*/
public auto(string nev,double benzinkapacitas)
public Double Range(Double minValue, Double maxValue)
{
Random random = new Random();
var x = random.NextDouble();
return x * maxValue + (1 - x) * minValue;
}
/*
soforpenze,autofogyasztasa,benzin,benzintankméret(30-200),adotthosszusaguut
*/
public auto(string nev,double benzinKapacitas, double megteendoUt)
{
Random random = new Random();
this.nev = nev;
this.benzinkapacitas = benzinkapacitas;
this.benzinKapacitas = benzinKapacitas;
this.megteendoUt = megteendoUt;
soforpenze = random.Next(10000,300000);
fogyasztas = random.Next(4,40);
benzin = random.NextDouble();
soforpenze = random.Next(10000,300000);
benzin = Range(0, benzinKapacitas);
hianyzoBenzin = ((megteendoUt / 100) * fogyasztas)- benzin;
}
}

53
SzimulaciOOP/benzinkut.cs Normal file
View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SzimulaciOOP
{
internal class benzinkut
{
public double benzin;
public int benzinAr;
public double kassza;
public Double Range(Double minValue, Double maxValue)
{
Random random = new Random();
var x = random.NextDouble();
return x * maxValue + (1 - x) * minValue;
}
public benzinkut()
{
Random random = new Random();
benzinAr = random.Next(350, 600);
benzin = Range(80000,150000);
}
//majd kell kerekíteni
public void tankol(auto kocsi)
{
Random random = new Random();
if (kocsi.soforpenze >= benzinAr * kocsi.hianyzoBenzin && kocsi.benzinKapacitas >= kocsi.hianyzoBenzin && kocsi.hianyzoBenzin <= benzin)
{
kocsi.soforpenze -= Convert.ToDouble(benzinAr) * kocsi.hianyzoBenzin;
kassza += Math.Round((Convert.ToDouble(benzinAr) * kocsi.hianyzoBenzin) , 0);
benzin -= kocsi.hianyzoBenzin;
Console.WriteLine($"{kocsi.nev} sikeresen tankolt és eljutott a célállomáshoz {kocsi.megteendoUt} km-re ");
// kocsi.soforpenze -= Convert.ToInt32((double.Parse(benzinAr.ToString())) * (kocsi.megteendoUt / kocsi.fogyasztas));
}
else
{
Console.WriteLine($"{kocsi.nev} leállt, nincs elég pénze vagy benzinje a cél eléréséhez, vagy nem volt már elég benzin a kúton");
}
}
}
}

37
SzimulaciOOP/fonok.cs Normal file
View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SzimulaciOOP
{
internal class fonok
{
public benzinkut Cegeskut;
public fonok()
{
//építtetünk a főnökkel egy kutat
Cegeskut = new benzinkut();
}
public void tankolnikuld(auto kocsi,benzinkut cegeskut)
{
cegeskut.tankol(kocsi);
}
public void megindit(string autonev, double autoutja, double autotankja)
{
auto kuldottkocsi = new auto(autonev, autotankja, autoutja);
if (kuldottkocsi.hianyzoBenzin <=0)
{
Console.WriteLine($"A küldött autó: {kuldottkocsi.nev} gond nélkül elérkezett a célhoz {kuldottkocsi.megteendoUt} km-re");
}
else
{
tankolnikuld(kuldottkocsi, Cegeskut);
}
}
}
}