public class Main{ static String name; static int attack, defence; public static void main(String[] args){ welcome(); set_name(); for(int i = 0; i<=4; i++){ encounter(); } } public static void welcome(){ System.out.println("Welcome to the Adventure Game!"); System.out.println("Your goal is to survive the challenge.\n"); } public static void set_name(){ System.out.println("Enter your character's name:"); name = kbin.nextLine(); System.out.println("Your character's name is set to:"+ name); } public static void roll_attack(){ attack = (int)(Math.random()*6)+1; } public static void roll_defense(){ defence = (int)(Math.random()*6)+1; } public static void encounter(){ System.out.println("\nAn goblin appears!"); //Call dice functions to update global variables roll_attack(); roll_defense(); System.out.println(name+" attacks with strength "+attack); System.out.println("Goblin defends with strength "+defence); if(attack > defence){ System.out.println("You defeated the goblin!"); }else if(attack < defence){ System.out.println("The goblin defeated you..."); }else{ System.out.println("It's a draw. You both walk away unharmed."); } } }