• 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

Java constructor

 
Greenhorn
Posts: 1
Android Firefox Browser Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have migrate it this question from stackoverflow.

I need to fill in the constructor for a person class. I am new to Java and programming in general. This is what I need to do:

TODO #1: Fill in the rest of the arguments to the Person constructor The Person constructor should take in 3 additional arguments: 1) String pictureName 2) int xCoord 3) int yCoord

TODO #2: Fill in the rest of this constructor
You need to create a local variable called picture and assign to picture the picture that we want to use.

TODO #3: You need need to move the picture to xCoord and yCoord. You can move the picture object by calling the translate method. the last step is to draw the picture.

And this is what I've done but I get an error, and I don't know why. I believe that's what I need to do unless I am missing something. If someone could help me figure this out and and explain this very clear it would be exceptionally appreciated.


 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to call method translate on String object.
String class does not have a translate method thus the error.

You need to create an object representing a picture given String with its name. Maybe it is in class Picture somewhere in your assignment?
I don't know. You didn't tell us. But it certainly is not String.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic