• Post Reply Bookmark Topic Watch Topic
  • New Topic

what's wrong with my code ?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


errors:
 
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the errors tells you EXACTLY what is wrong with your code.

time is an int. therefore, it has no .hours component you can access.
 
Mohamed Magdy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:the errors tells you EXACTLY what is wrong with your code.

time is an int. therefore, it has no .hours component you can access.

haha i'm still a beginner.anyway i got it thanks

fix:
public boolean compare(Time time){
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try replacing
public boolean compare(int time){

with

public boolean compare(Time time){
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Magdy wrote:
haha i'm still a beginner.anyway i got it thanks

fix:
public boolean compare(Time time){

Yup...I figured as much.

We don't like to GIVE the answers...I was trying to hint at it so that you would find it yourself. You are much more likely to remember it next time something like this comes up.

Well done!!
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using a boolean return on a compare method? That would tell you whether the two times are the same, not whether t1 is earlier or later than t2.
How did you work out the logic for adding seconds? What will happen if you add 120 seconds? That is two minutes. I would have thought the minutes variable increases by 2 and the seconds variable stays unchanged.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!