That might be the easiest answer, but it is by no means the correct answer. If you have got into a hole, working harder will simply make the hole deeper and you wearier. You might do well to leave off the exams, particularly if they test the rules and don't test whether you can program.Chester Dal wrote:. . . I know the easiest answer would be to "study harder" . . . .
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
At least it isn't me (I hope).Tim Holloway wrote:. . . a User Who Shall Remain Nameless. . . .
In my case, beer, beer, beer, beer, and beer (Carey Brown wrote:. . . what would generic requirements for ANY trip be? . . .
Tim Holloway wrote:Software pros know that a lot of our real work doesn't come from sitting at a desk 10 hours or more a day and pressing keys, but instead in bed at 3:00 AM or in the shower with no keyboard in sight.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
But it's actually 90% drinking, and 9% thinking, and 1% typing.fred rosenberger wrote:. . . software development is 90% thinking, and 10% typing.
Campbell Ritchie wrote:Please avoid quoting the whole of a previous post; that usually adds little to the discussion and is liable to deletion. Only quote the relevant parts please.
Campbell Ritchie wrote:none of your variables should be accessible outwith the class…
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Take it as given.Tim Holloway wrote:. . . Or should I just take it as given?
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:It should be noted that Campbell and I generally differ on the use of setters versus omnibus constructors. However, as this is both the bean and the main class, I, too would tend to favor constructor parameters.
More importantly, we both strongly agree that the primary logic for the app should NOT be in the main method or constructor. I usually have main() construct an instance, and the instance does its work in a method with a name of doIt() or something similarly original.
Don't know; please explain more about what you intend to do.Chester Dal wrote:So leave the main method on its own and utilise the other classes accordingly. . . .
That's a pleasureThank you.
More advice about the main() method from Winston Gutkowski here. I would write something like this:-The reason for making the method and constructor private is that they don't need to be called from outwith this class: note link to JLS (=Java® Language Specification). The app's logic can be run from execute(), and you can expand that class as you develop your other code.Tim Holloway wrote:. . . the primary logic for the app should NOT be in the main method or constructor. I usually have main() construct an instance, and the instance does its work in a method with a name of doIt() or something similarly original.
I don't like the concept that there is such a thing as a “main class” at all. The main() method is called that for historic reasons, to be similar to C and C++, but all it does is start the program off. I prefer not to think that classes live in some sort of hierarchy of importance.Chester Dal wrote:. . . Other books have the main class in one file and the rest of the data in another file.
Campbell Ritchie wrote:
I don't like the concept that there is such a thing as a “main class” at all. The main() method is called that for historic reasons, to be similar to C and C++, but all it does is start the program off. I prefer not to think that classes live in some sort of hierarchy of importance.Chester Dal wrote:. . . Other books have the main class in one file and the rest of the data in another file.
How have you got on with writing your code, even if a very basic form of it? And did you work out what my mistake yesterday was?
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
I am afraid I am not convinced you have. All you did was to write a load of setXXX() and getXXX() methods, which can expose implementation details. Most of the names of the fields can become obvious to other code. Your object doesn't do anything more than record the last data it was presented with. It fails to take care of itself because it doesn't do anything with those data; it doesn't even work out the total cost of the trip. If you wanted the total cost, you would have to add them up from outwith your object.Chester Dal wrote: . . . however i have encapsulated the data. . . .
Don't get me started about those stupid light bulbs. |