We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Please help
Page Index Toggle Pages: 1
Please help (Read 776 times)
Please help
Feb 18th, 2010, 6:38am
 
HI im toatally new to processing, ive been using Ben Fry's visualizing data book and working through the chapters. Im trying to edit chapter 6 so that instead of a map of USA a college map is loaded and when i type the name of my lecturer, their office is located on the map. This is my code for loading the data

static final int DEPARTMENT = 0;
static final int X = 1;
static final int Y = 2;
static final int NAME = 3;

int totalCount;  // total number of lecturers
Lecturer[] lecturers;
int lecturerCount;


// min/max boundary of all points
float minX, maxX;
float minY, maxY;


public void setup() {
 readData();
}

void readData() {
 String[] lines = loadStrings("lecturer.csv");
 parseInfo(lines[0]); // read the header line
 
 lecturers = new Lecturer[totalCount];
 for ( int i = 1; i < lines.length; i++){
   lecturers[lecturerCount] = parseLecturer(lines[i]);
   lecturerCount ++;
 }
}
void parseInfo(String line) {
 String infoString = line.substring(2);  // remove the #
 String[] infoPieces = split(infoString, ',');
 totalCount = int(infoPieces[0]);  
 minX = float(infoPieces[1]);
 maxX = float(infoPieces[2]);
 minY = float(infoPieces[3]);
 maxY = float(infoPieces[4]);
}

Lecturer parseLecturer(String line) {
 String pieces[] = split(line, TAB);
 
 String department = pieces[DEPARTMENT];
 String name = pieces[NAME];
 float x = float(pieces[X]);
 float y = float(pieces[Y]);
 
 
 return new Lecturer(department, name, x, y);
}




and  I used a second class called Lecturer


class Lecturer {
 String department;
 String name;
 float x;
 float y;
 
 
 public Lecturer(int department, String name, float x, float y) {
   this.code = code;
   this.name = name;
   this.x = x;
   this.y = y;
 }
}



when i run this I get the error
the constuructor test.lecturer(String, String, Float, Float) is undefined

if anyone can help me id really appreciate it.
Thanks in advance

Re: Please help
Reply #1 - Feb 18th, 2010, 6:58am
 
it's pretty much what it says.

your constructor is:
public Lecturer(int department, String name, float x, float y)...

but you're trying to use
new Lecturer(department, name, x, y);

where department is a String. so it's trying to find a (String, String, float, float) constructor. and failing.
Re: Please help
Reply #2 - Feb 18th, 2010, 7:00am
 
and given that your class is

class Lecturer {
String department;

then i think the constructor is wrong and should be taking a String as the first argument.
Re: Please help
Reply #3 - Feb 21st, 2010, 4:44am
 
thats great, thank you very much for your quick reply.
Page Index Toggle Pages: 1