Results 1 to 3 of 3

Thread: Return type required?

  1. #1
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Return type required?

    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.

    Code:
        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.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i knew it was something simple. Thanks once again.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •