This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Im trying to do a simple value passing operation i cant seem to get it working correctly. I have two classes one which produces a value and the other that needs that value to do something with it. I have written the code, although i do not get the right result, when i click the confirm button and enter how many tickets i would like the showID integer to be passed over to Cost class using method at the bottom of panel class. I think i have a problem with my call method as it is duplicating the fram twice after i enter a number into the input dialog. Heres my code:
I have highlighted areas of code that are the problem areas.
Does anyone have any ideas why im not getting the desired result ?
[ edited to break long lines of code -ds ] [ November 27, 2004: Message edited by: Dirk Schreckmann ]
A combination of more detail and less detail would be more helpful to all of us, I think. You didn't really specify very clearly where exactly the error was occurring and what results you were seeing and expecting. It seems like we'd have to read through all the code to try to first figure out where the problem is occurring...please try to be more specific...
To start I changed the class name from Panel to MyPanel (saver confusion with sun's Panel class)
Here's a few modifications, but there's still something wrong your 2nd panel is due to these 2 lines in Cost() Panel cust; cust = new Panel();
I changed those to a parent (if that is what you are trying to do)
the problem is here (in changing num1 = cust.getnum() to num1 = parent.getnum()) in MyPanel() num = 1, 2 or 3 so num1 = 1, 2 or 3 then your if/else tests for num1 > screen1, screen2 and screen3 (values are 50, 75, 100) so "Booking Not Accepted" is always the result. The if/else is also the wrong way around if > 50 else if > 75 else if > 100
if num1 is 100, the if > 50 will execute, which is probably not what you want perhaps these should be < 50 etc (or start at 100, and work back)
this line was also a problem if (day != "1" || month != "Apr" || year != "2004")
changed to !day.equals("1") etc
hope this makes sense
[ edited to remove the evil tab character and break long lines in the code -ds ] [ November 27, 2004: Message edited by: Dirk Schreckmann ]
As Stephen says, you still haven't provided the right information for us to help you. What happens when you compile and run this program? What is the output and how does this differ from what you expect? Where exactly in your code do things seem to be going wrong? If you can be more specific about your problems, we will be able to give you some more helpful information and hints about how to fix the problem.