wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Plese help!  I am very confuse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Plese help!  I am very confuse" Watch "Plese help!  I am very confuse" New topic
Author

Plese help! I am very confuse

Nancy Bradley
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
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

Joined: Jun 08, 2002
Posts: 3178
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!!!


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Nancy Bradley
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
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

Joined: Feb 25, 2004
Posts: 32
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

Joined: Jun 08, 2002
Posts: 3178
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

Joined: Feb 25, 2004
Posts: 32
Thanks.
Nancy B
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Plese help! I am very confuse