hello, i am writing a class that recieves a army time(800, 2400, ect) and assigns it a medicine that should be taken... i want my constructor to make int clock equal to the time the is sent to the class. how would i do that?
Long case statements like that always sound an alarm to me. They're a little hard to follow and could easily be a site of frequent change. So, how else can we associate a time with one or more meds? If the times are strictly on the hour, you might make a 24-slot array and put the meds for 12:00 midnight in slot 0, 1:00 in slot 1, etc. You'd have to convert 800 to 8 for example, but that sounds pretty easy. Another way to associate things is a Map. Maybe something like:
I suspect you are BRAND new to Java because of a number of syntax problems in your code, so I suggest you write the smallest possible piece of running code you can manage and work from there. Feel free to post your progress for more help! BTW: If you don't have a bookmark for the JDK docs, make one now! http://java.sun.com/j2se/1.4/docs/api/index.html You can look and see how Map works for you. Like, why did I make the time a String?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Free, earth friendly heat - from the CodeRanch trailboss