Results 1 to 13 of 13
  1. #1
    lonewolf1994 is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default can anyone help me out with my hw?

    hello.

    i've been trying to figure out this exercise all day.. the first exercise was hard enough, but i finally figured that one out, but this one is really confusing me..

    can anyone help me out with my hw?-captureeii.png

    nothing i do seems to work. and its really frustrating me that seem to understand wtf i have to do.. if anyone could offer tips, i would very much appreciate it

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: can anyone help me out with my hw?

    Is this a java programming problem? Post your code and your questions.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    lonewolf1994 is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default Re: can anyone help me out with my hw?

    Quote Originally Posted by Norm View Post
    Is this a java programming problem? Post your code and your questions.
    yes it is. and the code i need to make is for that picture, but i cannot figure out what the right code is

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: can anyone help me out with my hw?

    There must be some ideas in your class notes. I'm not familiar with what the picture represents.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: can anyone help me out with my hw?

    Here are the first steps;

    Java Code:
    public interface Person { ... }
    public class Employee implements Person { ... }
    public class Manager extends Employee { ... }
    You fill in the details ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    lonewolf1994 is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default Re: can anyone help me out with my hw?

    hey jos, thanks for this. but some of them are set to private and such
    • +: public, -: private, #:protected, ~:default
    • Employee is paid a rate per hour.
    • Manager is paid above + bonus.

    does that make things more complicated or? in any case, i'll try to work it out with how you suggested, and let you know if i got it working

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: can anyone help me out with my hw?

    Those +, -, # and ~ thingies are only another notation for private/public/etc. member variables and methods. It's a one-to-one translation to Java code; there's nothing complicated about it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: can anyone help me out with my hw?

    Oh come on, since you can clearly read the diagram then why have you not at least got the skeleton of the classes and interface in place?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    lonewolf1994 is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default Re: can anyone help me out with my hw?

    this is what i have done so far for the employee class
    package payroll;

    public class Employee implements Person {

    private int hoursWorked;
    private float payRate;

    public int gethoursWorked(){
    return this.hoursWorked;
    }

    public void sethoursWorked(int hoursWorked){
    this.hoursWorked = hoursWorked;

    }

    private float getpayRate(){
    return this.payRate;
    }

    private void setpayRate(float payRate){
    this.payRate = payRate;
    }

    }

    i got one question, the "get wage" is confusing me a bit... do i just do a getter for both classes and no setters?

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: can anyone help me out with my hw?

    Yes, as that's what the design says.

    Note the capitalisation of the method names, though.
    Yours are incorrect as they stand.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    lonewolf1994 is offline Member
    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0

    Default Re: can anyone help me out with my hw?

    Quote Originally Posted by Tolls View Post
    Yes, as that's what the design says.

    Note the capitalisation of the method names, though.
    Yours are incorrect as they stand.
    sorry, can you please elaborate on which i need to capitalize please?

    ah.. i noticed i was doing it wrong! i saw the ~ as a -.. so they aren't private... *facedesk*
    Last edited by lonewolf1994; 06-13-2012 at 06:37 PM.

  12. #12
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: can anyone help me out with my hw?

    Quote Originally Posted by lonewolf1994 View Post
    sorry, can you please elaborate on which i need to capitalize please?

    ah.. i noticed i was doing it wrong! i saw the ~ as a -.. so they aren't private... *facedesk*
    Those funny characters have nothing to do with capitalization whatsoever; Tolls was talking about, say, a member variable 'foo'; its getter and setter methods should look like getFoo() and setFoo( ... ). Check your method names again and especially their CamelCase capitalization.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: can anyone help me out with my hw?

    Yes, gethoursWorked != getHoursWorked (which is what the design in the first post is expecting).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •