PDA

View Full Version : Return type required?



craigtb
04-05-2007, 03:44 PM
I am again working on that project and am very close to being done. I have all but one class working. The error it is giving me is that it says a return type is required, but on all the other ones i have done i did not need a return type. Ill post the code then the error.


class Undergrad extends College
{
int[] tempAct, tempExercise, tempProject;

int ap, ex1, ex2, fEx;


public UnderGrad(String name, int age, String schoolName, int id, double gpa, int apCreds, String major, String minor, boolean time, int examOne, int examTwo, int[] activity, int[] exercise, int[] projects, int finalExam)
{
super(name, age, id, schoolName, gpa, major, minor, time);
tempAct = activity;
tempExercise = exercise;
tempProject = projects;
ap = apCreds;
ex1 = examOne;
ex2 = examTwo;
fEx = finalExam;
}

public String toString()
{
String A, E, P;
A = "";
for(int i = 0; i < 14; i++)
A += tempAct[i] + " ";
E = "";
for(int j = 0; j < 14; j++)
E += tempExercise[j] + " ";
P = "";
for (int k = 0; k < 14; k++)
P += tempProject[k] + " ";

String temp = super.toString();
return temp +"\nExam One Grade: "+ex1+ "\nExam Two Grade: "+ex2+"\nActivity Grades: "+A+"\nExercise Grades: "+E+"\nProject Grades: "+P;
}

}

the exact error i am getting is:
Undergrad.java:8: invalid method declaration; return type required
public UnderGrad(String name, int age, String schoolName, int id, double gpa, int apCreds, String major, String minor, boolean time, int examOne, int examTwo, int[] activity, int[] exercise, int[] projects, int finalExam)
^
1 error

I dont think it need s return type so it has to be somethign else that i am missing. Any help is greatly appriciated.

Twey
04-05-2007, 03:56 PM
It's not recognised as a constructor function because you've got the wrong case, Undergrad vs. UnderGrad. Also, as I've already said, convention and common sense would have you call it UnderGradCollege.

craigtb
04-05-2007, 05:08 PM
i knew it was something simple. Thanks once again.