Hi guys,
i've been stuck on one part of an assignment where i have to call a number 6 times from a different method/class.
I thought maybe doing a for loop calling its 6 times but i'm not sure how to call the method into the other method, this is what i have so far
private String getNextLottoNumber(String existingLottoNumbers){
int lottoNumber = 0;
boolean nextLottoNumber = false;
while (!nextLottoNumber){
lottoNumber = (int)(Math.random() * 40 + 1);
nextLottoNumber = checkIfUnique(lottoNumber, existingLottoNumbers);
}
return lottoNumber + "";
}
private boolean checkIfUnique(int lottoNumber, String existingLottoNumbers) {
String uniqueNumber = " " + lottoNumber + " ";
existingLottoNumbers = " " + existingLottoNumbers + " ";
int checkNumber = existingLottoNumbers.indexOf(uniqueNumber);
if(checkNumber == -1){
return true;
}else{
return false;
}
}
private String getLottoNumbersString() {
return "";
}
it all runs fine i just don't know how to then call the unique number 6 times in the getLottoNumbersString I would know how to do it if the lotto numbers were an array but we've been told not to use arrays so now im clueless, does anyone have n e pointers or hints as to how to do this?
thanks