Hi,
I'm an IT student taking up web site development. One of the courses we are taking is Java. Anyway, I have been trying to change two String arrays to Boolean's. I keep getting errors all the time, and am at my wits end! Could someone show me how to change them over???
Below is the entire application.
/**
Project name: plane.java
Author: I.T.Hemmy
Copyright: HemmySoft 2007
Description:
This program uses an array to let the user select one of 4 seats in first
or second class.
Created on October 24, 2007, 2:03 PM
**/
package planeapp;
//import the JOptionPane into the program
import javax.swing.JOptionPane;
public class plane {
public static void main(String[] args) {
//make the variables to be used in the application.
int whichClass = 0;
int t = 0;
int m = 0;
//Create the First Class Array
String class1Array[];
class1Array = new String[4];
//Put the desired data for each cell.
class1Array[0] = "first";
class1Array[1] = "first";
class1Array[2] = "first";
class1Array[3] = "first";
//Create the Second Class Array
String class2Array[];
class2Array = new String[4];
//Put the desired data for each cell.
class2Array[0] = "second class";
class2Array[1] = "second class";
class2Array[2] = "second class";
class2Array[3] = "second class";
//Start the main while loop process to handle the Inputs of the Confirmation dialogues held within the loop.
while( whichClass != 2 ){
whichClass = JOptionPane.showConfirmDialog(null, "Click Yes first class. Click No for second class. Click Cancel to exit.");
switch(whichClass){
//This case handles the "Yes" button, when pressed.
case 0:
int first = t++;
//If all the first class seats are full, then say they are.
if(t > 4)
{
JOptionPane.showMessageDialog(null, "We're sorry, all the first class seats are taken. If you are interested, please try second class.");
JOptionPane.showMessageDialog(null, "Thank you, have a nice day!");
}
//If any of the first class seats are empty, book a seat, and return to the main menu.
else
{
JOptionPane.showMessageDialog(null, "You have successfully booked a seat in: " + class1Array[first]);
}
break;
//This case handles the "No" button, when pressed.
case 1:
int second = m++;
//If all second class seats are full, then tell the user they are.
if(m > 4)
{
JOptionPane.showMessageDialog(null, "We're sorry, all the second class seats are taken. If you are interested, please try first class.");
JOptionPane.showMessageDialog(null, "Thank you, have a nice day!");
}
//If any of the second class seats are empty, book a seat, and return to the main menu.
else {
JOptionPane.showMessageDialog(null, "You have successfully booked a seat in: " + class2Array[second]);
}
break;
//If the "Cancel" button is clicked, this closes the program.
case 2:
JOptionPane.showMessageDialog(null, "Look behind you....");
JOptionPane.showMessageDialog(null, "BWA! Ha! Ha!!! You are done, have a nice day!");
break;
} //ends switch.
} //ends while.
}// end method main
}//end class
Have a great day!!