• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Plese help! I am very confuse

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
Nancy B
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic