1 Attachment(s)
Final Project Help Please? Due Tomorrow.
Attachment 1201
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 tanks 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.
Re: Final Project Help Please? Due Tomorrow.
Where are you having a hard time?
Re: Final Project Help Please? Due Tomorrow.
I am having a hard time trying to get it to fill/dump right. For now anyways.
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?
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.)
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?
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.
Re: Final Project Help Please? Due Tomorrow.
i added you to my yahoo messenger. if you want to talk on there
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.
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.
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
Re: Final Project Help Please? Due Tomorrow.
Quote:
Originally Posted by
tylerreece22
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.