i'm a realy newbie stil only been taking this course for a few months.
i have a problem with 2 things in the folowing codes and im gona ask ure help with them .
they are semi english since im in europe and these are codes the teachers used as an example and i dont really understand them tht wel .
the end item is some kind of lotto machine tht takes out numbers from the class "GlazenBol" aka glassbowl since tht is were we generate the numbers and shows them and then araanges them from low to hight with the exception of the 7th bal wich would be a joker .
public class Bal
{
private int nummer;
public Bal(int _nummer)
{
nummer = _nummer;
}
public int getNumber()
{
return nummer;
}
}
import java.util.*;
public class GlazenBol
{
public GlazenBol()
{
ballen = new Vector<Bal>();
vulBol();
}
private void vulBol()
{
for(int i=0; i<45; i++)
{
ballen.add(new Bal(i+1));
}
}
public int schepBal()
{
Collections.shuffle(ballen);
int returnvalue = ballen.remove(0).getNumber();
return returnvalue;
}
}
and lastly my test version
import java.util.*;
public class GlazenBolTest
{
private GlazenBol mijnBol;
public GlazenBolTest()
{
mijnBol = new GlazenBol();
ToonTestResultaten();
}
public void ToonTestResultaten()
{
System.out.println("\f");
for(int i=0;i<7;i++)
{
Collections.sort(mijnBol.schepBal);
//System.out.println("ball nummer" + (i));
System.out.println(mijnBol.schepBal());
}
}
}
what i dont understand is why my teacher uses "mijnBol.schepBal" in the println function to display numbers from the shepBal method in class galzenBol ? is he refering to GlazenBal first and then going to the method shepBal? can u please explain it better if possible?
secondly i tried to order them but i always get the error if i use any sort method and input schepBal or mijnBol.schepBal .
it says its not a variable wich i kind of understand but the method schepbal gives an int as result how would i go about making it a variable then or maybe put it in a list in order to sort them ?
sorry if this is asking to much if u have any sugestions it would be welcome .