How does the name affect class generation? The name of the class is the
name provided perhaps? If so, why would the user care about this
"implementation detail"?
-> In essence my program is to allow a user to create multiple Standard
Operating procedures for various recipes. The program starts off empty.
I was hoping to have the user create an instance of the standard
operating procedure class each time he wishes to enter a new receipe
and be able to do this indefinitely. However, im now thinking it would
be easier to instantiate a specific number of classes at runtime and
impose a limit this way.
> the code below doesnt
> work once never mind for numerous classes?????
> String help= TextField.getText();
> help = new SOP();
Is it possible to somehow extract the value of help above to create the
class rather than using the variable name???
Does SOP somehow extend String (even though String is declared to be
final)?
No, SOP is made up of a number of vectors. Thanks for your help, i feel
im getting out of my depth. cheers
glenn
Oliver Wong - 17 Mar 2006 17:06 GMT
> How does the name affect class generation? The name of the class is the
> name provided perhaps? If so, why would the user care about this
[quoted text clipped - 7 lines]
> be easier to instantiate a specific number of classes at runtime and
> impose a limit this way.
So why not have a class called "StandardOperatingProcedures", and create
instances of that class based on the name provided, rather than creating
whole new classes dynamically? E.g.
<pseudoCode>
String name = getUserInput();
SOP mySop = new SOP(name);
</pseudoCode>
>> the code below doesnt
>> work once never mind for numerous classes?????
[quoted text clipped - 10 lines]
> No, SOP is made up of a number of vectors. Thanks for your help, i feel
> im getting out of my depth. cheers
The code you gave above says you're assigning to help (which is of type
String) a new instance of SOP. If SOP doesn't extend String, then you're
going to have a type error, as help can only store objects of type String,
and SOP isn't of type String.
- Oliver
grahamsyuk - 17 Mar 2006 17:37 GMT
Oliver, cheers, i think the penny is finally starting to drop, glenn
Chris Smith - 17 Mar 2006 17:14 GMT
> -> In essence my program is to allow a user to create multiple Standard
> Operating procedures for various recipes. The program starts off empty.
[quoted text clipped - 3 lines]
> be easier to instantiate a specific number of classes at runtime and
> impose a limit this way.
I see no reason why you'd need to limit the user in terms of how many
objects he/she is allowed to create. I also don't see why doing this
would require creating classes dynamically. (I also wonder if you
really mean creating objects dynamically, rather than classes, which
would be a different matter. If so, this poor terminology has resulted
in a lot of confusion in this thread, and you should ignore Oliver's
reply because he took your question at face value.)
Looks like you just need to look into the collections API -- HashMap,
ArrayList, etc. -- rather than trying to solve this with the contortions
you are looking at.
> > the code below doesnt
> > work once never mind for numerous classes?????
[quoted text clipped - 4 lines]
> Is it possible to somehow extract the value of help above to create the
> class rather than using the variable name???
Let me guess at what you mean, since your question is completely
nonsensical. Did you mean that you want the contents of help to be a
variable name, and you want to initialize the variable of this name with
a new object of the SOP class? If so, you definitely want the
collections API, not what you're actually asking about.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation