Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Java help needed

Name: Rox 2009-12-13 7:47

Riiight, started doing Java few days ago and having troubles with this. I know the solution is really simple, I just can't work it out since I'm too much of a noob when it comes to programming.

Basically, I've got 2 private methods to assign time elements in hours and minutes and I wanna call them both through the public method setTime without having to duplicate the code in that method, how does one do this? What I've done with it kinda works, but it still let's values outside the range to be assigned so I have no clue what to do.

I'll be greatful for any pointers/help.

    /**
     * Sets the value of the hour field.
     * Values not in range (0 - 24) are discarded and replaced with zero.
     */
    private void setHour (int setHourTo)
    {
        if(setHourTo > 23) {
            this.hour = 0;
        }
        if(setHourTo < 0) {
            this.hour = 0;
        }
        else {
            this.hour = setHourTo;
        }
    }

     /**
     * Sets the value of the minute field.
     * Values not in range (0 - 59) are discarded and replaced with zero.
     */
    private void setMinute (int setMinuteTo)
    {
        if(setMinuteTo > 59) {
            this.minute = 0;
        }
        if(setMinuteTo < 0) {
            this.minute = 0;
        }
        else {
            this.minute = setMinuteTo;
        }
    }
       
     /**
     * Uses parameters from setHour and setMinute to set the time.
     * Only accepts values 0 - 23 for hours and 0 - 59 for minutes.
     * Any other values are discarded and replaced with a zero
     */
    public void setTime (int setHour, int setMinute)
    {
        this.hour = setHour;
        this.minute = setMinute;
    }

Name: Anonymous 2009-12-13 7:47

YOUR GAY

Name: Rox 2009-12-13 7:49

In other words, I'm trying to get setTime to do the same thing that both setHour and setMinute do, only without duplicating code.

Name: Anonymous 2009-12-13 8:34

public void setTime (int h, int m) {
setHour(h);
setMinute(m);
}

Name: Anonymous 2009-12-13 8:34

public void setTime (int h, int m) {
setHour(h);
setMinute(m);
}

Name: Anonymous 2009-12-13 8:35

>>4
>>5
Looks like I failed to post once! Please rape my face.

Name: Anonymous 2009-12-13 8:38

>>4
>>5

Somoene else already suggested this o na different board and it worked, but thanks anyway :) I feel like such a noob after realizing my mistake lol.

Name: Anonymous 2009-12-13 8:42

>>7
We've all been there. Good luck with the rest of your project.

Name: Anonymous 2009-12-13 8:52

>>8
We've all been there.
Have we.

Name: Anonymous 2009-12-13 9:15

>>8
Thanks

>>9
I still am, on a different part now though. But meh, need to figure this out on my own.

Name: Anonymous 2009-12-13 9:43

>>9
Humans know nothing ab initio. Before you learned Java, you didn't know Java. It's common sense.

Name: Anonymous 2009-12-13 11:01

privatevoid setHour (int setHourTo)
this.hour = setHour;


Did they ever teach you about return types?

Name: Anonymous 2009-12-13 11:02

>>12
I also fail at whitespace. Please rape my face too.

Name: Anonymous 2009-12-13 11:05

>>11
It's Frozenvoid undercovered!

Name: Rox 2009-12-13 21:45

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Rox 2009-12-13 21:45

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Anonymous 2009-12-13 21:48

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Rox 2009-12-13 23:12

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: The Cox 2009-12-13 23:26

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Rox 2009-12-13 23:31

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Anonymous 2009-12-13 23:32

Stop this shit.

Name: Anonymous 2009-12-14 5:31

Stop this shit.

Name: Anonymous 2009-12-14 5:53

1000 posts

Name: Anonymous 2009-12-14 7:11

This thread is threadstopped. You can't reply anymore.

Name: Anonymous 2009-12-14 7:20

1001 GET

Name: Anonymous 2009-12-14 7:37

sage

Name: Anonymous 2009-12-14 7:52

Stop this shit.

Name: Rox 2009-12-14 8:23

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Anonymous 2009-12-14 8:26

This thread is threadstopped. You can't reply anymore.

Name: Over 30 thread 2009-12-14 8:39

This thread is threadstopped. You can't reply anymore.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Name: Anonymous 2009-12-14 8:53

I hate you.

Name: Anonymous 2009-12-14 9:40

>>31
Oh c'mon. You love us.

Name: Anonymous 2009-12-14 10:09

1000 posts

Name: Rox 2009-12-14 10:57

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Rox 2009-12-14 11:09

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Anonymous 2009-12-14 13:59

Name: Anonymous 2009-12-14 13:59

This thread has been threadstopped. You can't reply anymore.

Name: Anonymous 2009-12-14 22:36

1000 posts

Name: Anonymous 2009-12-17 16:15

Ok its me again. I finished my Time class yesterday and now I'm working with 2 more classes - Patient and Date.

So far the Patiend class assigns a reference number, patient name, GP name and a date of birth. Now, I'm trying to get the Patient class to assign the date of birth for the Date class, and then to call a method from Date inside Patient to return the birth date, but this last bit seems not to work as I can't get Patient to assign the DOB values and pass them onto Date.

I'm not sure if it makes any sense, but here's what I have atm http://pastebin.com/m1f416a6d

Also I'm not supposed to change any code within Date, which is what confuses me since it would have been much easier to just do that, or am I missing the point here?

Name: Anonymous 2009-12-17 16:54

1000 posts

Name: Anonymous 2009-12-17 18:33

Are we going to get credit on this project?

Name: Anonymous 2009-12-17 19:15

1000 posts

Don't change these.
Name: Email:
Entire Thread Thread List