Re: Importing custom classes causes compile error

fnl <[email protected]> Sun, 26 Apr 2015 02:22:04 -0700 (PDT)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
Hi Mike,

Your messages are not disappearing. They just need to pass moderation so 
this forum is not polluted with spam. :-)

Your myBot class must extend your myUtils class, which contains your spin() 
method, but also make sure that you extend the AdvancedRobot class. :-)

Cheers,
- Flemming


Den søndag den 26. april 2015 kl. 11.00.29 UTC+2 skrev Mike Oliver:
>
> I'm going to try and repost this.  For some reason my original topic 
> disappeared.
>
> I am trying to clean up my robot code and make it more reusable by 
> creating custom classes.  Unfortunately I cant figure out how to access the 
> functions once they are imported.  I get compile errors. 
> Robowiki and repository I'm sure would allow me to figure this out, but 
> since they are both down, I have limited solutions.  Apologies for such a 
> newb question but any help would be appreciated.
>
> Mike
>
>
> myUtils.java (compiles)
> package mo;
> import robocode.*;
>
> public class myUtils extends AdvancedRobot{
>   public void spin() {
>     setTurnRight(10000);
>   } 
> }
>
>
> myBot2.java (doesnt compile)
> package mo;
> import robocode.*;
> import mo.myUtils;
>
> public class myBot2 {
>   public void run() {
>     while(true) {
>       spin(); 
>     }
>   } 
> }
>
>
> Compile Error:
> Compiling...
> ----------
> 1. ERROR in D:\MyFiles\Games\RoboCode\robots\mo\myBot2.java (at line 11)
> spin();
> ^^^^
> The method spin() is undefined for the type myBot2
> ----------
> 1 problem (1 error)
> Compile Failed (-1)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.