this was the Example:
********************************
want to create Market class with a name of vegetable in an Array of
String type, Stock of vegetables in an array of interts type and cost
of vegetables in an array of double type.
-method that can choose the order of vegetable selected by the user
and return the price of the vegetable.
- method that can provide the option of kowing the stock
availability
of the vegetable when the order of the vegetable is given as
parameter.
- method that can revice and order of the vegetable and the number
of items reqired .the price of the vegetable purchased with complete
details of the vegetable should be returned. once the stock of sales
occure the stock should be reduced for that vegetable . Promt the
user
for the insufficient stock of vegetable.
**
then in Client class , use menu driven program with proper validation
of all inputs
***************************************
this is what i have done
*****************************************
//please help me 2 finish this
import static javax.swing.JOptionPane.*;
public class Store22{
String veg[]={"Monday","Tus","Wed","The","Friday","Sat","Sun"};
int stock[]={32,43,5,4,5};
String getM(){
String order= ("no\t name\n");
//display output
for(int i =0 ;i<veg.length;i++){
order+=((i+1)+" - "+veg[i]+"\n");
}
order+="\nChoose any day";
int choice=Integer.parseInt(showInputDialog(order));
showMessageDialog(null,"you have selectred "+veg[choice-1]);
return order;
}
String getM2(){
String order= ("no\t name\n");
//display output
for(int i =0 ;i<veg.length;i++){
order+=((i+1)+" - "+veg[i]+"\n");
}
order+="\nChoose any veg";
int choice=Integer.parseInt( showInputDialog(order));
int order1=Integer.parseInt(showInputDialog("order No"));
//this is wrong, must change it to price.
showMessageDialog(null,"you have selectred
"+veg[choice-1]+"the price is "+
stock[choice-1]+"\n total price is :"+
stock[choice-1]*order1);
return order;
}
public static void main(String args[]){
Store22 s=new Store22();
s.getM2();
}
}
//end of class 1
******************
//start of Clint Class
import static javax.swing.JOptionPane.*;
public class CallStor
{
public static void main(String args[]){
String menu="Name List \n 1-check order "+
"1-calculate \n 2- Add\n3-"+
" Sort \n 4-sort marks \n5-Quit \n enter choice";
Store22 s=new Store22();
int opt=0;
do{
opt=Integer.parseInt(showInputDialog(menu));
switch(opt){
case 1:
s.getM();
System.out.println(s.getM());
break;
case 2:
s.getM2();
System.out.println("\n"+s.getM2());
}
}
while(opt >0 && opt<6);
}
}
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en