diff --git a/SzimulaciOOP.slnx b/SzimulaciOOP.slnx
index 3c658d1..39f8e36 100644
--- a/SzimulaciOOP.slnx
+++ b/SzimulaciOOP.slnx
@@ -1,3 +1,3 @@
-
+
diff --git a/SzimulaciOOP/Program.cs b/SzimulaciOOP/Program.cs
index 2f8710d..4c03c75 100644
--- a/SzimulaciOOP/Program.cs
+++ b/SzimulaciOOP/Program.cs
@@ -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);
}
}
}
diff --git a/SzimulaciOOP/SzimulaciOOP.csproj b/SzimulaciOOP/SzimulaciOOP.csproj
index 2c6acc6..9cc0426 100644
--- a/SzimulaciOOP/SzimulaciOOP.csproj
+++ b/SzimulaciOOP/SzimulaciOOP.csproj
@@ -44,6 +44,8 @@
+
+
diff --git a/SzimulaciOOP/auto.cs b/SzimulaciOOP/auto.cs
index 897e620..52b7042 100644
--- a/SzimulaciOOP/auto.cs
+++ b/SzimulaciOOP/auto.cs
@@ -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;
}
}
diff --git a/SzimulaciOOP/benzinkut.cs b/SzimulaciOOP/benzinkut.cs
new file mode 100644
index 0000000..4c94f67
--- /dev/null
+++ b/SzimulaciOOP/benzinkut.cs
@@ -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");
+ }
+
+
+ }
+ }
+}
diff --git a/SzimulaciOOP/fonok.cs b/SzimulaciOOP/fonok.cs
new file mode 100644
index 0000000..ebacf72
--- /dev/null
+++ b/SzimulaciOOP/fonok.cs
@@ -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);
+ }
+
+ }
+ }
+}