![]() |
| ||
| Clock.java 1 Attachment(s) Hello, first time poster here. So if I come off as asking something so hastily and quickly my bad, but currently I'm creating a clock class on DrJava. This is what I have so far. clock.java I have fullfilled most of the requirements that my profressor has asked except for a few. 1-A way to increment the time, so that if seconds/minutes goes >= 60 they become minute/hour. 2-Things displayed in the main Method: A:Create an array of objects called timeArray of type Time with 3 elements. B: Store the Time objects t1, t2, t3 in the array timeArray C: Display the time of all the objects in the array timeArray. Just incase of anymore questions, I have attached the file of the requirements of the clock class. So any tips/help would be helpful. Hope it dosen't sound like alot. |
| ||
| Re: Clock.java You should probably have your printTime ()function call the toString ()function. It's the same code. No sense writing it twice. Regarding going from 0 to 59 and 0 to 23 and not beyond, in your increment functions, use the / and % operators. Add the new amount to the old amount as you do, but then divide by 60 and take the mod of 60. For hours, it would be 24. public void incrementSeconds(int seconds) Do you have to worry about negative numbers at all? Not sure what the question is regarding the array. Do you not know how to declare an array? Do you not know how to write and read from it? |
| All times are GMT -4. The time now is 2:57 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC