behavior programming

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

behavior programming

Postby Shadowstep » Thu Mar 15, 2012 10:03 am

Hay everyone I am working on a project that uses behavior programming to drive around in a room and I wanted to start of just using the second example from http://lejos.sourceforge.net/nxt/nxj/tutorial/Behaviors/BehaviorProgramming.htm this page. But on the lines that say
Code: Select all
public HitWall(SensorPort port )
    {
       sonar = new UltrasonicSensor( port );
    }

it underlines the public hitwall(SensorPort port) in red and the error is "invalid method declaration; return type required"'t;

The problem is that I don't understand what should be in the place of SensorPort port.

greets pieter
Shadowstep
New User
 
Posts: 22
Joined: Sun Jan 15, 2012 9:24 pm

Re: behavior programming

Postby skoehler » Thu Mar 15, 2012 2:17 pm

HitWall is not a method, it is a constructor and should have the same name as the class. Probably you're copy/pasting to a class with a different name?
skoehler
leJOS Team Member
 
Posts: 1430
Joined: Thu Oct 30, 2008 4:54 pm

Re: behavior programming

Postby Shadowstep » Fri Mar 16, 2012 8:45 am

Hay, I managed to fix it I did not see there was more code on the bottom :p
But there is something I don't understand does al this code have to go in one file named BumperCar.java? bacaus I get some weird errors like Incorrect Package on the first line of code that says
Code: Select all
Import lejos.nxt.SensorPort;
Just saying this is the first time I work with lejos.

kind regards
Shadowstep
New User
 
Posts: 22
Joined: Sun Jan 15, 2012 9:24 pm

Re: behavior programming

Postby skoehler » Fri Mar 16, 2012 9:21 am

Post the complete output of nxjc - or are you using Eclipse?
skoehler
leJOS Team Member
 
Posts: 1430
Joined: Thu Oct 30, 2008 4:54 pm

Re: behavior programming

Postby Shadowstep » Tue Mar 20, 2012 6:48 am

I'm using netbeans.
Shadowstep
New User
 
Posts: 22
Joined: Sun Jan 15, 2012 9:24 pm

Re: behavior programming

Postby Shadowstep » Tue Mar 20, 2012 10:39 am

Never mind, I sloved it... don't really know what the problem was.
Shadowstep
New User
 
Posts: 22
Joined: Sun Jan 15, 2012 9:24 pm

Re: behavior programming

Postby tristram » Sun Apr 01, 2012 3:30 am

If you are posting copied code from your programme then the error that you got would be because the import statement does start with a capital letter.
tristram
New User
 
Posts: 2
Joined: Sun Apr 01, 2012 3:26 am


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

cron
more stuff