Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plese help! I am very confuse

 
Nancy Bradley
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an assignment where I am suppose to calculate area and perimeter of a rectangle.Then create an applet to test the first program. I am suppose to use constructors, but I do not undrstand too well how this work. I get a lot of error messages in the applet because it does not recognize the variables. Do I have to declare the variables again in the applet even though I am importing the first proigram? Please help
This is my code

[ April 05, 2004: Message edited by: Marilyn de Queiroz ]
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is!!! The ready-made program for you, but if I am not wrong, I think the formula for perimeter is wrong... U might need to change it as appropriate...

Here is the applet...

Don't forget to set the length of the output textfield to be able to view all the values... I do recommend strongly to learn the code that I provided and have fun with JAVA!!!
 
Nancy Bradley
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help.
I do not know what am I doing wrong. I still get 16 error messages : cannot resolve symbol for every time that one of this is in the code.
ActionEvent e
getContentPane()
lengthLabel
JLabel
JTextField
Thank you in advance for your help
Nancy B
 
Nancy Bradley
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it!
I had a few misspell words
thank you for all your help I really appreciate it.
I have a question. Why do you write mainX and mainY instead of just x and y?
Nancy B
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nancy Bradley:
I got it!
I had a few misspell words
thank you for all your help I really appreciate it.
I have a question. Why do you write mainX and mainY instead of just x and y?
Nancy B

I don't want the temporary values of x and y to be similar to main values in the object... mainX and mainY are instance variables, while x and y are used as method-scope variables... Hope it's helpful...
 
Nancy Bradley
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
Nancy B
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic