java - What to pass as parameters to constructor from super class -


i'm making abstract super item class, i'm not sure put parameters constructor. because item made of different subjects, i.e. course, student, have different parameters.

the constructor course

public course(string coursename, int coursenum) {      super();      this.coursenum = coursenum;      this.coursename = coursename; } 

and constructor student

public student(int studentid, string studentname) {     super();     this.studentname = studentname;     this.studentid = studentid; } 

so right super() constructor item not accept parameters, can't right either. i've tried subject, seems give examples variables super class used.

it common abstract super class not take constructor parameters. should consider in case, need common interface, not superclass.

you should think how use item object , how use student object. think through, item in application, attributes has etc. lead proper class design.

item should incorporate common attributes of subclasses. afraid, want inappropriately apply inheritance, since courses , students not have in common. say, wanted have class teacher , class student common superclass person contain gender, age, name etc.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -