I need to hand my program in soon and cant work out how to return the values i want from my methods.
My program is below:
package Booking;
import javax.swing.JOptionPane;
public class testing {
/**
* @param args
*/
public static void main(String[] args) {
String output, usersNum, address, date, lengthOfHire, numPeople, mountHelOutput, raceHelOutput;
int num, bookAnother;
int mountBike = 0, mountSmall = 0, mountMed = 0, mountLarge = 0, mountHelmet = 0, helmetOutput, mountMale = 0, mountFemale = 0;
int raceBike = 0, raceSmall = 0, raceMed = 0, raceLarge = 0, raceAccess = 0, raceMale = 0, raceFemale = 0, hapOutput;
int childBike = 0;
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");
numPeople = JOptionPane.showInputDialog("Please enter how many people the booking is for");
do {
while (num <1 || num > 3)
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;
mountMale = mountMale + mountBikeSex();
mountFemale = mountFemale + mountBikeSex();
mountSmall = mountSmall + mountFrame();
mountMed = mountMed + mountFrame();
mountLarge = mountLarge + mountFrame();
mountHelmet = mountHelmet + mountHel();
}
if (num == 2) {
raceBike = raceBike + 1;
raceMale = raceMale + raceSex();
raceFemale = raceFemale + raceSex();
raceSmall = raceSmall + raceFrame();
raceMed = raceMed + raceFrame();
raceLarge = raceLarge + raceFrame();
raceAccess = raceAccess + raceHel();
else
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);
System.exit(0);
}
}
public static int mountBikeSex () {
String output, usersNum;
int num, Male = 0, Female = 0;
output = "";
output = "Select if bike is for male or female \n\n";
output = output + "1 - Male \n";
output = output + "2 - Female \n";
do
{
usersNum = JOptionPane.showInputDialog(output);
num = Integer.parseInt(usersNum);
if (num == 1)
Male = Male + 1;
return Male;
if (num == 2)
Female = Female + 1;
return Female;
}while((num!=1)&&(num!=2));
}
public static int mountFrame (){
String output, usersNum;
int num, small, medium, large;
output = "";
output = "What frame size do you require? \n\n";
output = output + "1 - Small \n";
output = output + "2 - Medium \n";
output = output + "3 - Large \n";
usersNum = JOptionPane.showInputDialog(output);
num = Integer.parseInt(usersNum);
if (num == 1) {
small = small + 1;
}else if (num == 2) {
medium = medium +1;
}else if (num == 3) {
large = large +1;
}
return small;
return medium;
return large;
}
public static int mountHel () {
String mountHelOutput;
int helmetOutput, mountHel = 0;
mountHelOutput = "Do you require a helmet?";
helmetOutput = JOptionPane.showConfirmDialog(null, mountHelOutput, "Please Answer",
JOptionPane.YES_NO_OPTION);
if (helmetOutput == 0);
mountHel = mountHel + 1;
return mountHel;
}
public static int raceSex (){
String output, usersNum;
int num, Male, Female;
output = "";
output = "Select if bike is for male or female \n\n";
output = output + "1 - Male \n";
output = output + "2 - Female \n";
usersNum = JOptionPane.showInputDialog(output);
num = Integer.parseInt(usersNum);
if (num == 1);
Male = Male + 1;
if (num == 2);
Female = Female + 1;
return Male;
return Female;
}
public static int raceFrame() {
String output, usersNum;
int num, small, medium, large;
output = "";
output = "What frame size do you require? \n\n";
output = output + "1 - Small \n";
output = output + "2 - Medium \n";
output = output + "3 - Large \n";
usersNum = JOptionPane.showInputDialog(output);
num = Integer.parseInt(usersNum);
if (num == 1) {
small = small + 1;
}else if (num == 2) {
medium = medium +1;
}else if (num == 3) {
large = large +1;
}
return small;
return medium;
return large;
}
public static int raceHel() {
String raceHelOutput;
int hapOutput, mountHel, raceAccess;
raceHelOutput = "Do you require a helmet and panniers?";
hapOutput = JOptionPane.showConfirmDialog(null, raceHelOutput, "Please Answer",
JOptionPane.YES_NO_OPTION);
if (hapOutput == 0);
raceAccess = raceAccess + 1;
return raceAccess;
}
}
// TODO Auto-generated method stub
Basically all i need to do is be able to return the values from my methods so that they can be added on.... sounds simple but ive been battling with it for a while now and cant seem to work it out!!
mountBikeSex is the only method i have been fiddling around with to try and get working, thats why my methods are all slightly different
Help will be MUCH appreciated and thanks in advance
aLders x
This post has been edited by aLders: 04 January 2009 - 09:42 AM

New Topic/Question
Reply




MultiQuote










|