Page 2 of 2 FirstFirst 12
Results 21 to 34 of 34
  1. #21
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Java Code:
        /**
         * sets the colour to blue if LastReceived is true or red if Lastgiven is true
         */
        public void setColour(OUColour aColour) 
        {
          if (getLastReceived() == (true))
          {
             aColour = OUColour.BLUE;
             
           }
          if (getLastGiven() == (true)) 
          {
             aColour = OUColour.RED;
          }
       }
    You're asking for a parameter aColour here, but you're never using it. And you don't need it. Take that parameter out of the method declaration, and call setColour() within setLastReceived() and setLastGiven().

    -Gary-

  2. #22
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    OK so no GUI but you must be doing some sort of displaying. After you have changed the colour are you making another call to whatever method does the display?

  3. #23
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    thanks 4 the reply babes, i did try that and it told me missing identifier as i still had OUColour in the (), when i took it out my statements were no longer right.....or some error message like that.
    Thats what made sense to me at first. but with my specs it told me i have 2 take a single argument of type of OUColour....
    i feel like im going round in circles :(

  4. #24
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    hey junky
    yh but i dont have to call it.Its built into a gui that theyve given us to test. So i input
    MoneyFrog mf1 = new MoneyFrog("dave", "2345", 500);
    MoneyFrog mf2 = new MoneyFrog("dave", "2345", 900);
    mf1.share(mf2);

    and then open the graphics display and see my two green frogs :P

  5. #25
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Quote Originally Posted by smilinglady View Post
    but with my specs it told me i have 2 take a single argument of type of OUColour....(
    Post your spec. Not all of it, just the relevant part.

  6. #26
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    Its a bit hard 2 post all but the relevent ones....
    Write a public instance method setColour() method in MoneyFrog which takes a single argument of type...OUColour and returns no answer. The method should set the colour of the reciever to the value of the argument if the values of the boolean instance variables are appropriate. eg. setColour(OUColour.BLUE) sets the receiver to blue if its boolean var lastReceived is true under any other circumstances setColour() should have no effect

    wow :)

  7. #27
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    I also think the reason for the argument is so it overrides (i think thats the right term) the orginal method which must be in a really high up superclass.....but thats just me i may be wrong still learning :P

  8. #28
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    So follow the instructions exactly (well almost, ignore the example using OUColour.BLUE).

    Write a method called setColour. Done.
    Returns no answer (void). Done
    Has a single parameter of type OUColour. Done

    Now the tricky part.

    Set the receiver to the colour passed as a parameter (not just BLUE). Not done. Any colour can be passed and it must be set to that colour. Your code is hard coded to always set it to blue.

    Where in the specs does it say to set it to RED if lastGiven is true? get rid of that bit.

  9. #29
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Another problem I just noticed. You are setting the parameter aColour to BLUE and not the instance variable.

  10. #30
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    soz musta missed that bit darlin....similary setColour(OUColour.RED sets the reciever to red if its boolean var last given is true...........
    set the receiver to the colour passed. i tried that but once again im stuck on the reciever side...does that mean then...
    that OUColour.BLUE sould be OUColour.aColour......? or this.OUColour i tried that too

  11. #31
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    ye i would agree with u its only a local var but they told us to declare the instance vars at the beginning and didnt mention aColour i thought this and within the spec it doesnt tell you to assign an instance var like the others.
    Can i do it without it?

  12. #32
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    It is all a bit vague and confusing to me but if I understand correctly...
    Java Code:
    public void setColour(OUColour aColour) {
        if (lastReceived) { // access instance variables directly
            instanceVariable = aColour;  // obviously change instanceVariable to whatever the variable is actually called
            // or maybe even super.setColour(aColour)
            // but I am still unfamiliar with your assignment
        }
        if (lastGiven) {
            instanceVariable = aColour;
        }
    }

  13. #33
    smilinglady is offline Member
    Join Date
    Jan 2011
    Posts
    17
    Rep Power
    0

    Default

    yh dont make sense to me either the only instance var i have are
    /* instance variables */
    private boolean lastReceived;
    private boolean lastGiven;
    private Account account;
    and none of them are ok to use.
    The super doesnt work because its still not called anywhere or change the colours.
    Think im going to have to leave it and see where i went wrong.
    Ive tried my best...plus ur help :P
    thats all i can do
    thanks ever so much though
    i always feel alone learnin this stuff all my friends hate computers and love shoes...not that i dont :) (love shoes)
    thanks again

  14. #34
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Don't forget MoneyFrog extends Frog. So all public and protected variables in Frog are inherited by MoneyFrog.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Arguments
    By maya700 in forum New To Java
    Replies: 12
    Last Post: 02-01-2011, 06:57 PM
  2. Replies: 8
    Last Post: 09-23-2010, 01:07 AM
  3. Default Arguments
    By Mark Robert in forum New To Java
    Replies: 6
    Last Post: 08-17-2010, 03:56 PM
  4. Replies: 6
    Last Post: 04-05-2010, 10:58 PM
  5. repetition of 'arguments'(?)
    By Igor in forum New To Java
    Replies: 3
    Last Post: 12-13-2007, 11:08 AM

Posting Permissions

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