Computer Science Canada prob w/ OOP and importing |
Author: | mirhagk [ Wed Dec 16, 2009 9:55 am ] | ||||||
Post subject: | prob w/ OOP and importing | ||||||
What is it you are trying to achieve? To make a game with object oriented weapons What is the problem you are having? I have 3 types of program, the main program, the weapon class and the individual weapons (that could be expanded to 100's). I need to have all three in my game (I'd prefer not to just include the individual weapons in the main program) The only thing is that the weapons inherit the weapon class, and turing won't let me import that into it I can't put more than one class into a file that is to be imported Describe what you have tried to solve this problem Almost every combination of include, import w/e. If I have to I'll just include the weapons in the main file but I don't want to if I don't have to. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) the three programs are like the following: main program:
weapons.tu
cannon.tu
Please specify what version of Turing you are using 4.1 |
Author: | Superskull85 [ Wed Dec 16, 2009 10:14 am ] | ||||
Post subject: | Re: prob w/ OOP and importing | ||||
Change your import to:
Or if your class name matches the file name, and the two files are in the same directory:
Also unless you are creating a specific WEAPONS object within your CANNON you do not need to import and inherit the WEAPONS class into your CANNON class, just inherit it. |
Author: | mirhagk [ Wed Dec 16, 2009 11:28 am ] |
Post subject: | RE:prob w/ OOP and importing |
alright i figured out the problem, i had put the cannon object into a subfolder, and it messed up (even though it returned an error saying it couldn't find it the weapons class in the main folder) is there a way to put it in a folder?? |
Author: | Superskull85 [ Wed Dec 16, 2009 2:13 pm ] | ||||||||
Post subject: | Re: prob w/ OOP and importing | ||||||||
Sure. Relative paths:
Absolute paths:
You can do the same thing when inheriting classes as well. Relative paths:
Absolute paths:
|
Author: | mirhagk [ Wed Dec 16, 2009 4:17 pm ] |
Post subject: | RE:prob w/ OOP and importing |
no try to do it with those three sample programs. weapons.tu and cannon.tu are in a folder called weapons. thats what I was doing and it kept giving me an error when I tried to inherit it |