After a very quick look I can see no reason why you can't just add a
private LoadImage loadImg = new LoadImage(); to your class like you said - the constructor for LoadImage will do the necessary initialisation, so there's no need to add it to Brand's constructor. You will want a get method for it.
ps "LoadImage" sounds like a verb; it's not a good class name because it sounds like a method. How about changing it to BrandImage?
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
After a very quick look I can see no reason why you can't just add a
private LoadImage loadImg = new LoadImage(); to your class like you said - the constructor for LoadImage will do the necessary initialisation, so there's no need to add it to Brand's constructor. You will want a get method for it.
ps "LoadImage" sounds like a verb; it's not a good class name because it sounds like a method. How about changing it to BrandImage?
pps: This is a really stupid piece of code:
catch (IOException e) {
}
... if you have any kind of problem finding and reading the file you just told Java to throw away the error message it carefully constructed, and not tell you there was a problem at all.
Please put an e.printStackTrace() into the catch so you know what's happening.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
It's an Object-Oriented way of thinking, that classes represent things and methods represent actions, so class names will usually be nouns and method names usually verbs. This is NOT mandatory. You can call you classes (almost) anything you want. It's just that when I see a class name that is a verb then I suspect a problem with the thinking behind the design. That's all.
If you haven't covered try/catch yet in your course don't worry. Just put the line I told you inside the currently empty { } after the catch. It could save you hours of debugging time.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073