getWidth() | Coursera Community
Coursera Header
Solved

getWidth()


Badge +1
I can't change the width and hight of the image.
How can I do that ?
icon

Best answer by hamster 7 February 2019, 19:45

the clue is in the name. GetWidth

Get methods are usually 'read-only'; they tell you what something is but will not allow you to change the value. In order to change the value you need to call another function.

If you have a "getter method", chances are you also have a "setter method" as well. In programming its generally good practice to make the opposite function. For example, if you write code to 'open the door', you should also wrote code to 'close the door' as well.

So, with this all in mind, try this:

  • {Object}.SetWidth(some value)
* where {Object} is to be replaced with the class instance.

In the future though, its probably a good idea to be a bit more specific when posting problems. Language, Libraries, etc are all useful bits of information.

View original

2 replies

Hi @west c. It looks like this is a Java method. I'm familiar with JavaScript which is different. 🙂
If you are experiencing a problem with an assignment in a course, it's better to start a thread in the discussion forums of that course. This way your classmates might notice your thread and help you.
Userlevel 3
Badge +3
the clue is in the name. GetWidth

Get methods are usually 'read-only'; they tell you what something is but will not allow you to change the value. In order to change the value you need to call another function.

If you have a "getter method", chances are you also have a "setter method" as well. In programming its generally good practice to make the opposite function. For example, if you write code to 'open the door', you should also wrote code to 'close the door' as well.

So, with this all in mind, try this:
  • {Object}.SetWidth(some value)
* where {Object} is to be replaced with the class instance.

In the future though, its probably a good idea to be a bit more specific when posting problems. Language, Libraries, etc are all useful bits of information.

Reply

    Cookie policy

    We use cookies to enhance and personalize your experience. If you accept or continue browsing you agree to our cookie policy. Learn more about our cookies.

    Accept cookies Cookie settings