package Booking;
import java.awt.Component;
import javax.swing.JOptionPane;
public class testing {
static Component frame;
/**
* @param args
* @param frame
*/
public static void main(String[] args) {
String output, usersNum, name, address, date, lengthOfHire, numPeople, mountHelOutput, mountSexOutput, mountFrameOutput, raceSexOutput, raceFrameOutput, raceAccessOutput;
int num = 0;
int mountBike = 0, mountSmall = 0, mountMed = 0, mountLarge = 0, mountHelmet = 0, mountMale = 0, mountFemale = 0, sexOutput;
int raceBike = 0, raceSmall = 0, raceMed = 0, raceLarge = 0, raceAccess = 0, raceMale = 0, raceFemale = 0;
int childBike = 0, numLoop;
name = JOptionPane.showInputDialog("Please enter your FULL name");
address = JOptionPane.showInputDialog("Please enter your FULL address");
date = JOptionPane.showInputDialog("Please enter date for hire");
lengthOfHire = JOptionPane.showInputDialog("Please enter how long the hire will be for \n\n Enter in Number of days");
numPeople = JOptionPane.showInputDialog("Please enter how many people the booking is for");
numLoop = Integer.parseInt(numPeople);
int count = 1;
while ( count <= numLoop) {
count = count + 1;
do {
output = "";
output = "Select the bike you wish to purchase \n\n";
output = output + "1 - Mountain Bike \n";
output = output + "2 - Racing Bike \n";
output = output + "3 - Childrens Bike \n";
usersNum = JOptionPane.showInputDialog(output);
num = Integer.parseInt(usersNum);
if (num == 1) {
mountBike = mountBike + 1;
mountSexOutput = "Are you Male or Female?";
Object[] options = {"Male", "Female"};
sexOutput = JOptionPane.showOptionDialog(frame, mountSexOutput, "Please Answer",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
options, options[0]);
if (sexOutput == JOptionPane.YES_OPTION) {
mountMale = mountMale + 1;
} else if (sexOutput == JOptionPane.NO_OPTION) {
mountFemale = mountFemale + 1;
}
mountFrameOutput = "Would you like a Small, Medium or Large Frame?";
Object[] optionsFrame = {"Small", "Medium", "Large"};
int mFrame = JOptionPane.showOptionDialog(frame, mountFrameOutput, "Please Answer",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
optionsFrame, optionsFrame[2]);
if (mFrame == JOptionPane.YES_OPTION) {
mountSmall = mountSmall + 1;
} else if (mFrame == JOptionPane.NO_OPTION) {
mountMed = mountMed + 1;
} else if (mFrame == JOptionPane.CANCEL_OPTION) {
mountLarge = mountLarge + 1;
}
mountHelOutput = "Do you require a Helmet?";
Object[] optionsHel = {"Yes I do", "No I dont"};
int hel = JOptionPane.showOptionDialog(frame, mountHelOutput, "Please Answer",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
optionsHel, optionsHel[0]);
if (hel == JOptionPane.YES_OPTION) {
mountHelmet = mountHelmet + 1;
} else if (hel == JOptionPane.NO_OPTION) {
mountHelmet = mountHelmet + 0;
}
}
if (num == 2) {
raceBike = raceBike + 1;
raceSexOutput = "Are you Male or Female?";
Object[] optionsRace = {"Male", "Female"};
int raceSex = JOptionPane.showOptionDialog(frame, raceSexOutput, "Please Answer",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
optionsRace, optionsRace[0]);
if (raceSex == JOptionPane.YES_OPTION) {
raceMale = raceMale + 1;
} else if (raceSex == JOptionPane.NO_OPTION) {
raceFemale = raceFemale + 1;
}
raceFrameOutput = "Would you like a Small, Medium or Large Frame?";
Object[] optionsRFrame = {"Small", "Medium", "Large"};
int rFrame = JOptionPane.showOptionDialog(frame, raceFrameOutput, "Please Answer",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
optionsRFrame, optionsRFrame[2]);
if (rFrame == JOptionPane.YES_OPTION) {
raceSmall = raceSmall + 1;
} else if (rFrame == JOptionPane.NO_OPTION) {
raceMed = raceMed + 1;
} else if (rFrame == JOptionPane.CANCEL_OPTION) {
raceLarge = raceLarge + 1;
}
raceAccessOutput = "Do you require Helmet and Panniers?";
Object[] optionsPan = {"Yes I do", "No I dont"};
int rHel = JOptionPane.showOptionDialog(frame, raceAccessOutput, "Please Answer",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
optionsPan, optionsPan[0]);
if (rHel == JOptionPane.YES_OPTION) {
raceAccess = raceAccess + 1;
} else if (rHel == JOptionPane.NO_OPTION) {
raceAccess = raceAccess + 0;
}
}
if (num==3) {
childBike = childBike + 1;
JOptionPane.showMessageDialog(null, "Helmet is included with bike and must be worn!", "A Message",
JOptionPane.INFORMATION_MESSAGE);
}
}
while (num <1 || num > 3);
}
String finalBooking;
finalBooking = " Booking Information" +
"\n\nName: " + name +
"\nAddress: " + address +
"\nDate of Hire: " + date +
"\nNumber of People: " + numPeople +
"\nThe Hire is for: " + lengthOfHire + " Days" +
"\n\nYou Have Booked:" +
"\n\n" + childBike + " Childrens Bikes" +
"\n\n" + mountBike + " Mountain Bikes:" +
"\n " + mountMale + " Male" +
"\n " + mountFemale + " Female" +
"\n " + mountSmall + " Small Frames" +
"\n " + mountMed + " Medium Frames" +
"\n " + mountLarge + " Large Frames" +
"\n " + mountHelmet + " Helmets" +
"\n\n" + raceBike + " Racing Bikes:" +
"\n " + raceMale + " Male" +
"\n " + raceFemale + " Female" +
"\n " + raceSmall + " Small Frames" +
"\n " + raceMed + " Medium Frames" +
"\n " + raceLarge + " Large Frames" +
"\n " + raceAccess + " Helmet and Panniers" +
"\n\n\n You may wish to keep a copy of this \n\n Click OK to complete order";
JOptionPane.showMessageDialog(null, finalBooking, "Booking Details",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
// TODO Auto-generated method stub
Thanks in advance
x

New Topic/Question
Reply




MultiQuote



|