public static void main(String[] args) {
// Local variable declared
int selectValue;
// Main Menu is displayed
System.out.println("| Flight Travel Systems |");
System.out.println("|--------------------------|");
System.out.println("| Options: |");
System.out.println("| 1. Time |");
System.out.println("| 2. Price |");
System.out.println("| 3. Hotels |");
System.out.println("| 4. End |");
System.out.println("============================");
selectValue();
}
public static void selectValue()
{
int choice = -1;
while(choice < 0)
{
String input = JOptionPane.showInputDialog("Please select an option: ");
choice +=1; // used to dismiss the unlimited loop
if (input.equals("1")){
System.out.println("Time");
}
else if (input.equals("2")){
System.out.println("Price" );
}
else if (input.equals("3")){
System.out.println("Hotels " );
}
else if (input.equals("4")){
System.exit(1);
}
else {
JOptionPane.showMessageDialog(null, "User error,please select an option");
choice-=1; // return to original page
}
}
}
}
At the moment there is a mixture of GUI and CLI but that doesnt matter at the moment. Ok so when running the program it asks you to select a option from 4. When I enter 1. it takes me to a page where i can work out the time it takes to get from airport to destination. i have created a time class.
import java.util.Arrays;
public class Time {
public static void main( String [ ] args)
{
String[] airport = new String[4]; //set up a string array with four positions.
int i;
for (i=0; i <airport.length; i++) //loop below is used to display the string of array
{
System.out.println(airport[i]);
}
}
How do i link these two classes so when i enter the value 1 the list of airports appears. i want to link these two classes so if (input.equals("1") ) it displays the list of airports
Bookmarks