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 12 of 12

Thread: Final Project Help Please? Due Tomorrow.

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Final Project Help Please? Due Tomorrow.

    Final Project.zip
    I am having a terribly hard time getting this to work.

    Introduction:
    The system consists of a tank of water with a filling line that allows water to flow into the tank and a dumping line that removes water from the tank. The water level in the tank must always be maintained between the low water danger level and the high water danger level. If the level of water in the tank exceeds the high water level, the dumping line begins emptying the tank until it falls below the high water level. If the level of water in the tank falls below the low water level, the filling line begins filling the tank until the water level reaches the safe zone. You must create a program that allows the tank operator to see the status of the tank and active the filling and dumping pumps manually, or switch the system to automatic leveling mode. The user must also be able to switch the flow rate of the filling and dumping lines between several predefined rates. The following is just a sample interface, you can be creative. Note that this is just a simulation; you just need to decide on what capacity tank you have and what capacity indicates low and high level the visual does not have to be scaled to adjust to the calculation and the rate of flow.

    General Requirements:
    Make appropriate use of classes and methods to simplify the design and support the abstraction of the various data objects and operations. Do not create many classes in one file. Try to have a separate file for each class.
    You MUST put the required comment information at the beginning of every class you write and use appropriate comments throughout the code to explain general functionality.
    User Interface Requirements:
    • A single JFrame must be used for the application
    • The high level or low level indicator lights should change to red color when the water level in the tank is not within required levels
    • Upon exiting the application, it must save the state of the application to an output file of a specified format.
    • Upon starting the application, it must load the previously saved state from a file.
    • The system shall monitor the level of water within the virtual water tank.
    • Upon the tank water level hitting a critical level, the system shall notify the user of the situation.
    • The system shall allow for automatic level control of the water tank’s filling and dumping operations (open for interpretation).
    • The system shall allow for manual filling and dumping of the water in the virtual tank.
    • The system shall allow for the water to be filled or dumped at various predefined flow rates.


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    Where are you having a hard time?

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    I am having a hard time trying to get it to fill/dump right. For now anyways.

  4. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    Is it compiling?

    I'm getting these errors:

    DropButtons.java:14: type javax.swing.JComboBox does not take parameters
    JComboBox<?> fillingRate = new JComboBox<Object>(rates);
    ^
    DropButtons.java:15: type javax.swing.JComboBox does not take parameters
    JComboBox<?> dumpingRate = new JComboBox<Object>(rates);
    ^
    DropButtons.java:14: type javax.swing.JComboBox does not take parameters
    JComboBox<?> fillingRate = new JComboBox<Object>(rates);
    ^
    DropButtons.java:15: type javax.swing.JComboBox does not take parameters
    JComboBox<?> dumpingRate = new JComboBox<Object>(rates);
    ^
    4 errors

    I know it should take parameters, but why am I getting that error?

  5. #5
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    I fixed that. It would seem that it only really dumps when you're either at the top, or even worse, more than overflowed.

    Perhaps first you should try and make it so that it can't go higher than the top. (A real tank would spill outwards, not rise into the air.)

  6. #6
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    I am really not sure. I am trying to get the fill, dump, and auto to paint right. Did you find anything on that?

  7. #7
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    No, but I think I noticed something interesting.

    if (e.getSource() == fill) {
    tank.fillingWater();
    tank.repaint();
    }
    else if (e.getSource() == dump) {
    tank.dumpWater();
    tank.repaint();
    }
    else if (e.getSource() == auto) {
    tank.autoLevel();
    tank.repaint();
    tank.setAuto(!tank.getAuto());
    repaint();
    }

    I think with Objects you use the .equals() method, not ==.

    Also, paintComponent is a protected method of JPanel.
    Last edited by javapenguin; April 23rd, 2012 at 12:44 AM.

  8. #8
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    i added you to my yahoo messenger. if you want to talk on there

  9. #9
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    It seems that in Buttons.java, if you remove the

    tank.repaint() and repaint() parts, then the weird glitchy painting goes away, though it won't update. So the error is something to do with those.

    It is tank.repaint().

    Also, I noticed the problem I think.

    In the tank paintComponent, you called paintComponents, not paintComponent. Could that be the problem?


    public void paintComponent(Graphics g) {
    super.paintComponents(g);

    g.setColor(Color.blue);
    //water
    g.fillRect(245, 450-waterLevel, 249, waterLevel);
    //-------------------------------
    g.fillRect(25, 75, 150, 25);

    g.setColor(Color.red);
    g.drawRect(247, 150, 246, 200);
    g.fillRect(600, 425, 150, 25);

    g.setColor(Color.black);
    //int[] x = {245, };
    //g.drawPolyLine(245, 75, 250, 375);
    g.drawRect(245, 75, 250, 375);
    g.drawLine(245, 75, 450, 75);



    Yep, that got rid of the glitchy paint errors.
    Last edited by javapenguin; April 23rd, 2012 at 01:07 AM.

  10. #10
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    Wow! Dude...you just helped so much! Now it doesnt do the glitchy painting and it just paints normal, so i have to update the "lights" and the auto fill now so they work right.

  11. #11
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    now i am just trying to get the lights to change as i go over the red boundary lines

  12. #12
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Final Project Help Please? Due Tomorrow.

    Quote Originally Posted by tylerreece22 View Post
    now i am just trying to get the lights to change as i go over the red boundary lines
    Okay, and what have you tried? Where are you stuck?

    You'll get better help faster if you provide an SSCCE that demonstrates the problem instead of making people download your entire project.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. JAVA1 - Final Project
    By ch103 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 12th, 2011, 02:48 PM
  2. Final Project - Trivia Game
    By Goforit in forum Java Theory & Questions
    Replies: 5
    Last Post: May 14th, 2011, 05:56 AM
  3. final project idea
    By zulqar in forum AWT / Java Swing
    Replies: 4
    Last Post: November 3rd, 2010, 07:28 AM
  4. final project idea
    By zulqar in forum Java Theory & Questions
    Replies: 1
    Last Post: November 1st, 2010, 12:02 PM
  5. java Final Project Error
    By JavaStudent_09 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: August 21st, 2010, 09:23 PM