Reputation:
The compiler gives me the error "'void' type not allowed here...<= operator cannot be applied to java.lang.String,int...not a statement"
getHours() and getSeconds() return instance variables of type int. Any help would be much appreciated.
if (userCommand.equals("a")) {
yourClock.advance();
System.out.println(yourClock.getSeconds());
System.out.println("The time is now" +
(yourClock.getHours()) <= 9 ? ".0" : ".") +
yourClock.getHours() +
(yourClock.getMinutes() <= 9 ? ".0" : ".") +
yourClock.getMinutes() +
(yourClock.getSeconds() <= 9 ? ".0" : ".") +
yourClock.getSeconds();
Upvotes: 0
Views: 142
Reputation: 1980
it looks like you are closing a printout too early
(yourClock.getHours()) <= 9 ? ".0" : ".") +
the closing ) after
getHours())
is closing your printout.
Upvotes: 2
Reputation: 6879
Let's just look at this statement:
(yourClock.getHours()) <= 9 ? ".0" : ".")
Don't you think you are short of a '(' here?
It's better like this:
((yourClock.getHours() <= 9) ? ".0" : ".")
Upvotes: 0
Reputation: 10834
You are closing your println
in the wrong place. You are closing it after the first getHours() call it should be
if (userCommand.equals("a")) {
yourClock.advance();
System.out.println(yourClock.getSeconds());
System.out.println("The time is now" +
(yourClock.getHours() <= 9 ? ".0" : ".") +
yourClock.getHours() +
(yourClock.getMinutes() <= 9 ? ".0" : ".") +
yourClock.getMinutes() +
(yourClock.getSeconds() <= 9 ? ".0" : ".") +
yourClock.getSeconds());
Upvotes: 3