Re: non-static method cannot be referenced from a static context

Posted 05 April 2010 - 06:46 AM

Please sort out the indentation in the future as in the UseUniversity class, it does make it hard for us to read .

Anyways, This bit here

University std1 = new University ("Jad", 201004442, "Mechanical");
University std2 = new University ("Seta", 201005062, "Computer");
University std3 = new University ("omar", 201040611, "Electrical");
University std4 = new University ("tarek", 200903072, "Civil");
University std5 = new University ("Sana", 20094442, "Mechanical");
University std6 = new University ("reham", 200805062, "Computer");
University std7 = new University ("omar", 200740611, "Electrical");
University std8 = new University ("Mazen", 200803072, "Civil");
University std9 = new University ("Ahmad", 200804442, "Mechanical");
University std10 = new University ("abd", 200705062, "Computer");
University std11 = new University ("ibrahim", 200840611, "Electrical");
University std12 = new University ("Mark", 200603072, "Civil");

Make this an ArrayList of objects like this..

ArrayList<University> student = new ArrayList <University>();

As you later are invoking the AddCOE211() method will all-1 of the objects which you can do using a for loop.

You can then add each object like this and fill out the constructor.

student.add(new University("Jad", 201004442, "Mechanical"));

This will then let you easily create as many student objects.

As for your methods not being found, check what you defined your methods as..

There isnt a method called AddCOE211Lab();

But there is a method called AddCOE211LAB();

See the typo?

Same for this..

std4.paytuition();

should be

Paytuition(); instead of paytuition()

Your method getfinalgrade needs these parameters as you created it like this

Re: non-static method cannot be referenced from a static context

Posted 05 April 2010 - 07:07 AM

Also please avoid posting again, posting twice dosent help us as i was actually working on this post what is wrong in my class?whilst PennyBoki was working on this one. Which for 1, makes things confuzing and secondly, double the work for us.