Skip to main content

Help me =(

1 reply [Last post]
inimitable
Offline
Joined: 2008-08-26
Points: 0

i using abstract method ,

and always prompt out wiv" not abstract and does not override abstract method " tis kind of error

ublic abstract class Person
{
protected Name name;
protected String address;
protected String hp;
protected String eadd;
private static int counter;

Person(Name name,String address,String hp,String eadd){

this.name = new Name(name);
this.address = address;
this.hp = hp;
this.eadd = eadd;
}

Person()
{
}

public void setName(Name n)
{
name = new Name(n);
}
public void setAddress(String address)
{
this.address = address;
}

public String getAddress()
{
return address;
}
public void setHp(String hp)
{
this.hp = hp;
}

public String getHp()
{
return hp;
}

public void setEadd(String eadd)
{
this.eadd = eadd;
}

public String getEadd()
{
return eadd;
}

public String getName()
{
return name.getName();
}

public String getTitle()
{
return name.getTitle();
}

public static void setcounter()
{
counter++;
}

public static int getcounter()
{
return counter;
}
public static void setcounter2()
{
counter--;
}

public abstract void setOfficeRN(String officeRN);
public abstract void setDiv(String div);
public abstract void setSchoolID(String schoolID);
public abstract void setCourse(String course);
public abstract void setSchool(String school);
public abstract void setRegisterNo(int registerNo);
public abstract String getOfficeRN();
public abstract String getDiv();
public abstract String getSchoolID();
public abstract String getCourse();
public abstract String getSchool();
public abstract int getRegisterNo();
public abstract boolean equals(Person person);
public abstract void makeCopy(Person person);

public String toString()
{
return "Name " + getTitle() +"." + getName() +"\n Address " + getAddress() + "\n Handphone Number " + getHp() + "\n Email Address " + getEadd();
}
}

--------------------------------------------------------------------------
public class Members extends Students{
protected int registerNo;

Members(Name name,String address,String hp,String emailAddress,String schoolID,String course,String school,int registerNo){
super(name,address,hp,emailAddress,schoolID,course,school);
this.registerNo = registerNo;
}

public void setRegisterNo(int registerNo)
{
this.registerNo = registerNo;
}

public int getRegisterNo()
{
return registerNo;
}

public boolean equals(Person m)
{
boolean equal = false;
if(this.name.equals(m.name)){
if(this.eadd.equals(m.eadd)){
if(this.hp.equals(((Students)m).schoolID)){
equal = true;
}
}
}return equal;
}

public void makeCopy(Person m){
this.name = m.name;
this.address = m.address;
this.hp = m.hp;
this.eadd = m.eadd;
this.schoolID = ((Students)m).schoolID;
this.course = ((Students)m).course;
this.school = ((Students)m).school;
this.registerNo = ((Members)m).registerNo;
}
public String toString(){
return super.toString()+"\nRegister Number:"+registerNo;
}

}

------------------------------------------------------------------------
public class Name {

private String title;
private String name;

Name(String title , String name)
{
this.title = title;
this.name = name;
}

Name(Name name)
{
this.title = name.title;
this.name = name.name;
}

public void setName(String name)
{
this.name = name;
}

public String getName()
{
return name;
}

public void setTitle(String title)
{
this.title = title;
}

public String getTitle()
{
return title;
}
}
------------------------------------------------------------------------
public class Lecturers extends Person{

private String div;
private String officeRN;

Lecturers(Name name, String address, String hp, String eadd, String div, String officeRN)
{
super(name,address,hp,eadd);
this.div = div;
this.officeRN = officeRN;
}

Lecturers()
{
}

public void setDiv(String div)
{
this.div = div;
}

public String getDiv()
{
return div;
}

public void setOfficeRN(String officeRN)
{
this.officeRN = officeRN;
}

public String getOfficeRN()
{
return officeRN;
}

public void makeCopy(Person l){
this.name = l.name;
this.address = l.address;
this.hp = l.hp;
this.eadd = l.eadd;
this.div = ((Lecturers)l).div;
this.officeRN = ((Lecturers)l).officeRN;
}

public boolean equals(Person l)
{
boolean equal = false;
if(this.name.equals(l.name)){
if(this.eadd.equals(l.eadd)){
if(this.hp.equals(((Lecturers)l).hp)){
equal = true;
}
}
}return equal;
}

public String toString(){
return super.toString()+"\nDivision:"+div+"\nOffice Room Number:"+officeRN;
}

}
----------------------------------------------------------------------
public class Students extends Person{

protected String schoolID;
protected String course;
protected String school;

Students(Name name, String address, String hp, String eadd, String schoolID, String course, String school)
{
super(name,address,hp,eadd);
this.schoolID = schoolID;
this.course = course;
this.school = school;
}

Students(){}

public void setSchoolID(String schoolID)
{
this.schoolID = schoolID;
}

public String getSchoolID()
{
return schoolID;
}

public void setCourse(String course)
{
this.course = course;
}

public String getCourse()
{
return course;
}

public void setSchool(String school)
{
this.school = school;
}

public String getSchool()
{
return school;
}

public void makeCopy(Person s)
{
this.name = s.name;
this.address = s.address;
this.hp = s.hp;
this.eadd = s.eadd;
this.schoolID = ((Students)s).schoolID;
this.course = ((Students)s).course;
this.school = ((Students)s).school;
}

public boolean equals(Person s)
{
boolean equal = false;
if(this.name.equals(s.name)){
if(this.eadd.equals(s.eadd)){
if(this.schoolID.equals(((Students)s).schoolID)){
equal = true;
}
}
}return equal;
}

public String toString()
{
return super.toString()+"\nId:"+schoolID+"\nCourse:"+course+"\nSchool:"+school;
}
}
------------------------------------------------------------------------
public class TaskOne {

public static void main(String args[]){

Name name1 = new Name("Mr","Kong Fook Shen");
Person person1 = new Students(name1,"D4-10,JLN Awana","0166809599","kfshen12@hotmail.com","07WAD03773","DIA2","SAS");
Name name2 = new Name("Dr","Inimitable");
Person person2 = new Lecturers(name2,"D3-10,JLN Awana","0166809959","Inimitable@yahii.com","Computer Science","A323");
Name name3 = new Name("Mrs","Kong");
Person person3 = new Members(name3,"D2-10,JLN Awana","0166809559","Kong12@hotmail.com","07WAD07733","DIA2","SOS",443211);
Person person4 = new Lecturers();

System.out.println(person1);
System.out.println(person2);
System.out.println(person3);
person4.makeCopy(person2);
System.out.println(person4);
System.out.println(person2.equals(person4));
System.out.println(person2.equals(person3));

Person person5 = new Students();

Name name4 = new Name("Sir","Shen");
person5.setName(name4);
person5.setAddress("D1-10,JLN Awana");
person5.setHp("0166809995");
person5.setEadd("Shen12@hotmail.com");
person5.setSchoolID("07WAD07337");
person5.setCourse("DIT2");
person5.setSchool("SAS");
System.out.println(person5.getName()+"\n"+person5.getAddress()+"\n"+person5.getHp()+"\n"+person5.getEadd()+"\n"+person5.getSchoolID()+"\n"+person5.getCourse()+"\n"+person5.getSchool());
}

}
p-----------------------------------------------------------------------

Whenever I run my task

C:\Students.java:10: Students is not abstract and does not override abstract method getRegisterNo() in Person
public class Students extends Person{
^
C:\Lecturers.java:10: Lecturers is not abstract and does not override abstract method getRegisterNo() in Person
public class Lecturers extends Person{
^
2 errors

Process completed.

HELP PLS!!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ismailatalay
Offline
Joined: 2008-11-25
Points: 0

Because "getRegisterNo" is an abstract method, you must implement this method in subclasses (Students & Lecturers) of superclass (Person).

If you don't want to implement, at least you have to open and close curly brackets {}