Results 1 to 1 of 1
- 04-16-2009, 04:40 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 1
- Rep Power
- 0
Working on a menu program...using exceptions
Hello all,
I am working on a project and I could use some script help. I have been recently learning about exceptions and inheritance. I need to add more to this program and I could use some script help...thanks in advance!
1) I must get the menu items (1-9) to work for GadgetInventory. So far, I already done menu items#5 and 9. I am trying to work on the others.
2) I must implement Serializable for the blueprint classes.
3) I must generate JavaDocs via *.html file. I know how to do this already.
** I am trying to get this program to work with my previous program called Gadget!
For the record, I am using Java 6.0 with Eclipse software 3.2.2
This is what I have so far.....
--------------------------------------------------------------------------
import java.util.*;
public class GadgetInventory {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ArrayList<Gadget> Gadget = new ArrayList<Gadget>();
MenuInfo mi = new MenuInfo();
Gadget.add(new Gadget(300, 45.00, 200, "blue, round"));
Gadget.add(new Gadget(200, 30.00, 250, "red, long"));
Gadget.add(new Gadget(250, 54.00, 320, "pink, square"));
Gadget.add(new Gadget(5000, 23.00, 5500, "black, large"));
Gadget.add(new Gadget(430, 10.00, 480," brown, small"));
Gadget.add(new Gadget(10, 77.00, 20, "green, smelly"));
Gadget.add(new Gadget(450, 21.00, 500, "red, fruity"));
Gadget.add(new Gadget(65, 20.00, 34, "purple,heavy"));
Gadget.add(new Gadget(87, 4.00, 95,"yellow, oblong"));
Gadget.add(new Gadget(35, 32.00, 50,"white, flat"));
int ans=0;
while (true)
{
menu();
System.out.println("CHOICE:");
ans = scan.nextInt();
if (ans==1)
{
// read serializable
Gadget=mi.readSerializable();
}
if (ans==2)
{
// write serializable
mi.writeSerializable(Gadget);
}
if (ans==3)
{
// total value of all inventory
mi.total(Gadget);
}
if (ans == 4)
{
// list all Gadgets below reorder level
mi.reorder(Gadget);
}
if (ans == 5)
{
// print all Gadgets
mi.print(Gadget);
}
if (ans==6)
{
// find a Gadget by id number
mi.find(Gadget);
}
if (ans==7)
{
// add a Gadget
mi.addGadget(Gadget);
}
if (ans==8)
{
// delete a Gadget (ask them for the number first)
mi.deleteGadget(Gadget);
}
if (ans==9)
{
System.out.println("See you later!");
System.exit(0);
}
}
}
public static void menu()
{
System.out.println("\n1. read a serializable file");
System.out.println("2. write to a serialized file");
System.out.println("3. find the total value of all inventory");
System.out.println("4. list all Gadgets below reorder level");
System.out.println("5. print all Gadget information");
System.out.println("6. find a Gadget by Gadget id number");
System.out.println("7. add a new Gadget");
System.out.println("8. totally delete a Gadget");
System.out.println("9. exit\n");
}
}
Similar Threads
-
need menu program
By student_doesntget_java in forum New To JavaReplies: 2Last Post: 03-20-2009, 09:58 AM -
Program working fine on netbeans but not when run with jar file
By nvlachos in forum Advanced JavaReplies: 2Last Post: 03-16-2009, 07:52 PM -
My program is not working
By MICHAELABICK in forum New To JavaReplies: 6Last Post: 12-22-2008, 11:05 PM -
Need help putting Exceptions in my program.
By Loop in forum New To JavaReplies: 6Last Post: 10-13-2008, 11:48 PM -
Menu item not working properly for mouse events
By Preethi in forum New To JavaReplies: 1Last Post: 09-23-2008, 08:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks