keszverzio Verzio 1
This commit is contained in:
53
SzimulaciOOP/benzinkut.cs
Normal file
53
SzimulaciOOP/benzinkut.cs
Normal 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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user