PDA

View Full Version : OOP inheritance


jimmy_bbq
03-05-2003, 01:07 AM
Dear everyone,
Is it possible to define the method like this:

Class GameEntity
DoKeyMethod (whichKey)
DoCollisionMethod (whichEntity)
DoStepMethod()


GameEntity:: DoKeyMethod(whichKey)
Switch (whichKey){
Case keyLeft: DoKeyLeftMethod()
Case keyRight: DoKeyRightMethod()


Class Bat : public GameEntity //inherit from GameEntity

Bat:: DoKeyMethod():: DoKeyLeftMethod()
Move the Bat left

Thanks in advance.
jimmy

chrismiceli
03-05-2003, 01:18 AM
i have no clue what you are talking about, if you want to make a method (function) you can do it in a few ways

hello = new function();
function hell();

Skyzyx
03-05-2003, 01:22 AM
Some of that syntax, yes, but not all of it. Remember that Java/C++ has absolutely nothing to do with JavaScript, but I know that some of that notation is allowed.

I'd ask beetle, jkd, or Vladdy...

jimmy_bbq
03-05-2003, 02:04 AM
so sorry......I should have put it at Java forum.....I thought it's Java forum........sorry

beetle
03-05-2003, 05:20 AM
Hehe, ya, Java != Javascript :D

Javascript can do limited inheritance, though. I'll post and example if anyone is curious :p

Beck
03-05-2003, 05:34 AM
funny you should offer that, beetle, I'm definitely curious. Examples and links are both appreciated, if you have the time. Thanks!

beetle
03-05-2003, 06:37 AM
Eh, I don't have the time right now. Just Google "javascript inheritance" and you'll find some interesting reading

Here's a good one
http://www.pbwizard.com/Articles/class_inheritance.htm

Roelf
03-05-2003, 07:48 AM
here is another good one:
http://www.kevlindev.com/tutorials/javascript/inheritance/index.htm