program.cs
HogerLager HL = new HogerLager();
Foutmelding fm = new Foutmelding();
do
{
fm.vraagGetal();
if (HL.getRandom() == fm.getGetal())
{
fm.drukCorrect();
}
else
{
if(HL.getRandom() > fm.getGetal())
{
fm.drukHoger();
}
else
{
fm.drukLager();
}
}
}
while(HL.getRandom() != fm.getGetal());
////////
Foutmelding.cs
int intGetal;
public void vraagGetal()
{
Console.WriteLine("Geef een getal.");
intGetal = Convert.ToInt32(Console.ReadLine());
}
public int getGetal()
{
this.vraagGetal();
return intGetal;
}
public void drukHoger()
{
Console.WriteLine("Het getal is hoger.");
}
public void drukLager()
{
Console.WriteLine("Het getal is lager");
}
public void drukCorrect()
{
Console.WriteLine("Het getal is correct");
}
/////////
HogerLager.cs
int intAantal;
Foutmelding fm = new Foutmelding();
Random rnd = new Random();
public void Random()
{
intAantal = rnd.Next(1, 11);
}
public int getRandom()
{
this.Random();
return intAantal;
}