-
November 13th, 2001, 06:05 AM
#1
Java Program
This was an assignment in my CS151 Programming Fundamentals aka. Java class. Its supposed to be a cuckoo clock simulator. I know it pretty dumb, but I was wondering what the programming experts around here see that I can do to slim it down a little bit. In its current state it is over 5 pages long. By the way there is a lot of documentation with it because the teacher requires it.
Wine maketh merry: but money answereth all things.
--Ecclesiastes 10:19
-
November 13th, 2001, 07:51 AM
#2
Senior Member
Re: Java Program
I gave it a try - what can I say, I was bored!
I added error handling for the input. So, basically:
- if they enter a non-integer as a start or end time it will prompt again.
- if the enter a start time that is later than the end time it will prompt again
- if their input is <0 or >24 then it prompts again
Not sure if you counted seconds as ticks but if you do, change
Code:
s += "*tick* ";
ticks++;
to just
If that doesn't work gimme a shout and I can help you out some more.
- Stronzo
\"Vini, Vici, Vidi\"
I came, I saw, I conquered.
- Julius Caesar
-
November 13th, 2001, 11:42 AM
#3
Never ask a script kiddie to do a programmers job...
If you're really interested in good advice, post a slightly more specific question at www.javajunkies.org and you should get some excellent advice.
-
November 13th, 2001, 11:47 AM
#4
Yeah I know its a boring program, but the teacher doesnt want us doing anything exciting for fear we might learn something. He did this to show those in the class who have never programmed, how to do the "for" loop Thanks for the help. The method I wrote to handle bad numbers looks like this:
num = getInt(startHour)
public static int getInt(int hour)
{
while(hour > 12 || hour < 1)
{
JOptionPane.showErrorMessage("Please enter number between 1 and 12");
JOptionPane.showInputDialog("Enter start hour");
}
return hour;
}
Wine maketh merry: but money answereth all things.
--Ecclesiastes 10:19
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|