• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why can't I refer to setLenght frm this class?  RSS feed

 
Dirk Lucas
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I try to get the following code to work. I made a class(Rechthoek) with a constructor and getters and setters.

Now, I am trying to make a second class which should create several "rechthoek" objects (setting values in the code of the Rechhoekapplicatie class -->which also acts as main class). However I can't seem set the values in the code; the setter methods won't do it.

I treid: Rechthoek.setLengte() but for some reason the program tells me I need a method setLengte, but I already have a settermethod (setLengte) for it! I do not get it! Can anyone tell me where I am going wrong in the following code?

(Edit: to shed some light on the names used --> rechthoek = retangle lengte=lenght and breedte=width.)

Class1:


Class 2:


So...can anyone please shove me into the right direction??
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dirk Lucas wrote:
So...can anyone please shove me into the right direction??



From a very quick look, here are two issues...

1. The setLenght() method is an instance method. You actually need an instance to be able to call it. Only static methods can be called with just the class name to qualify it.

2. The signature of the method must match. You actually don't have a setLenght() method that takes no parameters.

Henry
 
Dirk Lucas
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah! Thanks I got it!

There was more wrong than just that, but I think my question might not have been the clearest either;)

I thank you for your reply!

Kr.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!