This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
My classes are calculating and doing the math properly but when I try to pass a string answer to the main class Assignment2Activity.java it show up as null. I'm conducting system.out.println line throughout the project to confirm that my answers are showing up and are correct but when I try to pass the string to the class that extends Activity it fails. But if I try to pass the string to the driver or calculations class it works fine. Any thoughts? I created a getAnswerPassed() and getAnswerToPass in the TimeDifferenceDriver and TimeDifference classes to see if that would change anything and it still shows up as null in the Assignment2Activity class. I've been looking up info on the web and it seems that by extending activity it makes things more difficult, is that true? Any help is appreciated. Thanks
Your problem is not with the class that extends Activity, you have a basic logic problem, in the method getAnswerPassed() of the class TimeDifferenceDriver you are creating an object of type TimeDifference and all properties or instance variables are initialized to default value and a default value of String is null. Once created the object TimeDifference you immediately call method getAnswerToPass() and you get null.
I hope help you and sorry by my english
Joined: Apr 26, 2012
Thank you that was pretty much it. I combined the TimeDifference.java and TimeDifferenceDriver.java into the Calculations.java class. Originally I thought the classes were getting too large but the teacher says compared to a real word development environment they were tiny. Also Mario your English was fine.
subject: String not passing to class that extends Activity