Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How would i fix this Java Code?

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How would i fix this Java Code?

    I am taking a java course and one of the assignments is to make a basic order calculator, like the ones from a Restaurant, so far i was able to make it do everything but display the names of the foods.
    here is the code:

    public FlameBay ()
    {
    money = new DecimalFormat("0.00");

    mp = new MenuItem[9];
    mp[0] = new MenuItem("Egg Noodles", 1.0);
    mp[1] = new MenuItem("Spaghetti", 0.95);
    mp[2] = new MenuItem("Ramen", 0.5);
    mp[3] = new MenuItem("Beef", 2);
    mp[4] = new MenuItem("Chicken", 1.5);
    mp[5] = new MenuItem("Pork", 1.25);
    mp[6] = new MenuItem("Kung Pao", 0.5);
    mp[7] = new MenuItem("Teriyaki", 0.25);
    mp[8] = new MenuItem("Curry", 0.45);


    LayoutManager some_layout = new BorderLayout();
    setLayout(some_layout);
    add(r,BorderLayout.CENTER);
    add(clear,BorderLayout.NORTH);
    add(checkout,BorderLayout.SOUTH);

    comp_callback dosomthing = new comp_callback();


    checkout.addActionListener(dosomthing...
    clear.addActionListener(dosomthing);

    JPanel center_panel = new JPanel();
    LayoutManager some_layout2 = new GridLayout(3,3);
    center_panel.setLayout(some_layout2);
    MenuItem amenuitem[] = mp;
    int x = amenuitem.length;
    for(int y = 0; y < x; y++)
    {
    MenuItem menuitem = amenuitem[y];
    menuitem.addActionListener(dosomthing);
    center_panel.add(menuitem);
    }




    getContentPane().add(center_panel, "West");

    setTitle("Flame Bay");
    setSize(500,400 );
    setDefaultCloseOperation(JFrame.EXIT_...
    setVisible(true);


    }
    any suggestions?


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: How would i fix this Java Code?

    Welcome! Please read Announcements - What's Wrong With My Code? topic to learn how to post code correctly and other useful info for new members.

Similar Threads

  1. How to fix annoying white splash in this simple java code?
    By t342532 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 10th, 2013, 09:19 AM
  2. Please help! Passing variables between modules.
    By Aberdeen in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 7th, 2013, 10:18 PM
  3. Replies: 3
    Last Post: April 27th, 2013, 07:19 AM
  4. [SOLVED] New to JAVA, problem with first code, need to know how to fix.
    By hrenfrow in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 22nd, 2013, 11:17 AM
  5. Help me to fix this code
    By rcbandit2 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 31st, 2011, 02:30 PM