Hello, iam quite new to this, i will try to explain what i want to code ,
a HiLo game where the user can choose up to 3 different levels(1-10, 1-100, 1-1000)
with these 3 methods
public static void main(String[] args) {…}
public static int playGame(int maxNumber) {...}
public static void giveResponse(int answer, int guess) {…}
with no Random , i will use the:
int number = (int)(Math.random() * max) +1; to generate numbers
I have tried so many times , but i don't get it ,
my code so far
import java.util.Scanner;
public class HL{
public static void main(String[] args ){
Scanner s = new Scanner(System.in);
System.out.println("Välkommen till HiLo!");
System.out.println("Vilken svårighetsgrad?");
System.out.println("1. Lätt (1-10)");
System.out.println("2. Mellan (1-100)");
System.out.println("3. Svårt (1-1000)");
playGame(10);
playGame(100);
playGame(1000);
} public static int playGame(int maxNumber){
int guessCount=0;
int max;
int choice;
int number=(int)(Math.random()*maxNumber)+1;
Scanner s = new Scanner(System.in);
choice=s.nextInt();
if (choice == 1){
System.out.println("Gissa på ett tal mellan 1-10");
}else if(choice == 2) {
System.out.println("Gissa på ett tal mellan 1-100");
}else if(choice == 3) {
System.out.println("Gissa på ett tal mellan 1-1000");
while (guessCount > number){
guessCount=s.nextInt();
System.out.println("Gissningen var för låg");
guessCount=s.nextInt();
} if(guessCount < number) {
guessCount=s.nextInt();
System.out.println("Gissningen var för hög");
}
}
return guessCount;
}
public static void giveResponse(int answer, int number){
}
}