Jump to content

 

So i should delete those two statements?

public Clock(int minute, int hour){                this.minute = minute;                this.hour = hour;                }

That's up to you. hour % 60 is definitely incorrect, though.

The first value you pass to the constructor is minute, the second is hour. That's why your output is 55:012.

Link to post
Share on other sites

That's up to you. hour % 60 is definitely incorrect, though.

The first value you pass to the constructor is minute, the second is hour. That's why your output is 55:012.

okay i switched them around i'm still getting the same result

So i should change it to hour%24 right?

Link to post
Share on other sites

 

like:

public Clock(int minute, int hour){                this.hour =hour;                this.minute = minute;                }

That constructor is equivalent to the original.

The order in which you assign the values is irrelevant. When you called "new Clock(12, 55)" the minute parameter is set to 12 and the hour parameter is set to 55. If you want to call your constructor like "new Clock(hour, minute)" then you need to change your constructor to accept parameters in that order.

Link to post
Share on other sites

That constructor is equivalent to the original.

The order in which you assign the values is irrelevant. When you called "new Clock(12, 55)" the minute parameter is set to 12 and the hour parameter is set to 55. If you want to call your constructor like "new Clock(hour, minute)" then you need to change your constructor to accept parameters in that order.

So i gotta change what's in the parentheses?

Link to post
Share on other sites

So i gotta change what's in the parentheses?

I'll give you an example:

Suppose I have a class called Widget:

class Widget {    int x, y;    Widget(int firstParameter, int secondParameter) {        this.x = firstParameter;        this.y = secondParameter;    }}

If I create a new Widget like this:

Widget w = new Widget(12, 55);

then firstParameter will be set to 12 and secondParameter will be set to 55.

 

In your Clock constructor, the first parameter is set to minute and the second is set to hour. Your options are: swap minute and hour in the constructor parameter list or call the clock constructor like this: "new Clock(55, 12)"

Link to post
Share on other sites

I'll give you an example:

Suppose I have a class called Widget:

class Widget {    int x, y;    Widget(int firstParameter, int secondParameter) {        this.x = firstParameter;        this.y = secondParameter;    }}

If I create a new Widget like this:

Widget w = new Widget(12, 55);

then firstParameter will be set to 12 and secondParameter will be set to 55.

 

In your Clock constructor, the first parameter is set to minute and the second is set to hour. Your options are: swap minute and hour in the constructor parameter list or call the clock constructor like this: "new Clock(55, 12)"

okay i did that and i got this:

My Clock: 0:00
Your Clock: My Clock (add 1 Minute): 0:01
My Clock (add 5 Minutes): 0:06
My Clock (add 1 Hour): 1:06
Your Clock (twelve hours later): 0:55
Your Clock (five minutes later): 0:00
Link to post
Share on other sites

 

okay i did that and i got this:

My Clock: 0:00
Your Clock: My Clock (add 1 Minute): 0:01
My Clock (add 5 Minutes): 0:06
My Clock (add 1 Hour): 1:06
Your Clock (twelve hours later): 0:55
Your Clock (five minutes later): 0:00

 

Your addHours and addMinutes are not correct.

Link to post
Share on other sites

Your displayTime method is printing nothing. If you haven't changed what you posted earlier, the only time nothing will be printed is when minutes >= 10.

 I changed it to this

if(this.minute>59){                System.out.println((hour%24)+ ":0" +(minute%60));                      }else  if(this.hour>23){                System.out.println((hour%24)+ ":" +(minute%60));
Link to post
Share on other sites

 

So adding twelve hours changes the time from 1:06 to 0:55? That doesn't sound right....

 

okay i somehow fixed it. Everything is showing up except for YourClock. The output is:

My Clock: 0:00
Your Clock:
My Clock (add 1 Minute): 0:01
My Clock (add 5 Minutes): 0:06
My Clock (add 1 Hour): 1:06
Your Clock (twelve hours later): 0:55
Your Clock (five minutes later): 1:00
Link to post
Share on other sites

 

okay i somehow fixed it. Everything is showing up except for YourClock. The output is:

My Clock: 0:00
Your Clock:
My Clock (add 1 Minute): 0:01
My Clock (add 5 Minutes): 0:06
My Clock (add 1 Hour): 1:06
Your Clock (twelve hours later): 0:55
Your Clock (five minutes later): 1:00

 

I still don't understand why 12 hours after 1:06 is 0:55. Shouldn't it be 13:06?

Is "Your Clock" a different clock to "My Clock"?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×