Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Mutator method at Beginner level

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mutator method at Beginner level

    Here's the intruction
    The mutator for
    speedInKperHour will check its parameter and use the parameter only if it is not a
    negative number.

    The mutator for driverStanding takes no parameters. It checks the
    speed – if speed is 60 or less, standing will be “no ticket”, if speed is 80 or less,
    standing will be “small ticket” and if speed is more than 80, the standing will be “big
    ticket”.



    Sorry
    I'm not really sure what Mutator to use for these two


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Mutator method at Beginner level

    Mutators are used to mutate an instance's attribute, here e.g. setSpeedinkph(int newSpeed)

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Mutator method at Beginner level

    Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.

  4. #4
    Member Ganeprog's Avatar
    Join Date
    Jan 2014
    Location
    Chennai,India
    Posts
    80
    My Mood
    Love
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default Re: Mutator method at Beginner level

    Hi,

    Mutator means its a setter method. It just assigns a new values to the variable. As per your requirement, for example you code like this

     
    public void setSpeedInKperHour(int speed)   
    {
                 //Your code goes here
    }

    still you have any doubts post here.

    thanks,

Similar Threads

  1. Rather beginner level programming; need assistance.
    By waltershc in forum What's Wrong With My Code?
    Replies: 21
    Last Post: February 6th, 2013, 07:05 PM
  2. Very beginner level code help needed.
    By dcalabro in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 13th, 2013, 06:26 PM
  3. Help with beginner mutator method
    By Dysun in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 8th, 2012, 06:32 PM
  4. Quick, beginner-level Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 01:06 PM
  5. What is the matching mutator method?
    By ssmith in forum Object Oriented Programming
    Replies: 1
    Last Post: November 3rd, 2009, 10:03 PM