• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance with array

 
Cougar Vis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i use inheritance with array, where the array is stored in the Superclass (first level), then subclass for the methods?

Where can i find some examples for this?
 
john guthrie
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you mean this (which you can do):




or this (which you cannot):

 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you describe the problem you are trying to solve with this approach? Also give some more detail about what you are trying to do. I'm not quite sure what you are asking about.

Also, have you tried to write code and compile it? In the end, the compiler is the ultimate arbiter that decides what you can and cannot do in the language.

Layne
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CougarV12,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

Thanks Pardner! Hope to see you 'round the Ranch!
 
Cougar Vis
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marilyn de Queiroz:
CougarV12,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

Thanks Pardner! Hope to see you 'round the Ranch!


hmmm...what's wrong with my name, been using it since then ?
Cougar actually is my nick name, V12 = Vis


=======================================================================

I have no idea how to do and not sure whether you can use array in inheritance.

What i wanted to do is
Eg. 5 Radio cars each one of them can only have 2 action either "F" "B" "L" & "R".
I needed to use inheritance to save on the coding which it possiblely could, but not sure how to use array with it, so it store their action in the superclass, then execute the method in their subclasses
[ November 23, 2004: Message edited by: Cougar Vissert ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic