54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
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");
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|