I created an array of three integers that I ask input to the user, then I return that array and instantiated the class, but I don't have access to the array items:
import java.util.Scanner;
public class Input {
public static int[] getInput() {
Scanner sc = new Scanner (System.in);
int choice[] = new int[3];
System.out.println("Type the options: ");
System.out.println("Plate: ");
choice[0] = sc.nextInt();
System.out.println("Dessert: ");
choice[1] = sc.nextInt();
System.out.println("Drink: ");
choice[2] = sc.nextInt();
return choice;
}
}
Main class:
public class Main
{
public static void main (String [] args) {
Menu menu = new Menu();
Input input = new Input();
menu.ShowMenu();
Input.getInput();
//I want to compare choice[0] here
if (input.getInput() == 1) {
//code block
}
Do I need to write a method to the three choices? I just want to pass the three user inputs to use in the Main class if's and else's.