Results 1 to 6 of 6

Thread: Need Help

  1. #1
    Inimitable is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

    Exclamation Need Help

    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:"+cour se+"\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","07WAD0 3773","DIA2","SAS");
    Name name2 = new Name("Dr","Inimitable");
    Person person2 = new Lecturers(name2,"D3-10,JLN Awana","0166809959","Inimitable@yahii.com","Comput er Science","A323");
    Name name3 = new Name("Mrs","Kong");
    Person person3 = new Members(name3,"D2-10,JLN Awana","0166809559","Kong12@hotmail.com","07WAD077 33","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.get Eadd()+"\n"+person5.getSchoolID()+"\n"+person5.get Course()+"\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!!

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    General Rules of Thumb:
    1) The more code you post the fewer people who will read it. Solution: Post enough code so that it compiles, but limit this to only code that is related to your problem.
    2) Code that is hard to read will likely not get read. Solution: use code formatter tags to help your code keep its formatting.

    Needless to say, I didn't read your whole code (sorry, but it makes my eyes bleed), but your error suggests that you have two classes that extend the abstract class Person, but that don't implement all of Person's abstract methods. Solution, make sure that the subclasses implement all of Person's abstract methods. Also make sure that the method signatures (i.e., access modifiers, parameters, spelling, and capitalization) match exactly.

    Good luck.
    Last edited by Fubarable; 08-27-2008 at 06:40 AM.

  4. #4
    Inimitable is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

    Default Re: Need Help

    Mod, may proceed to closed or remove this thread thanks

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,032
    Rep Power
    6

    Default Re: Need Help

    This has to be a record!! A member has two posts. The first is to ask a question. The second post comes about six years later saying it's okay to close the thread.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    Inimitable is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

    Default Re: Need Help

    Quote Originally Posted by jim829 View Post
    This has to be a record!! A member has two posts. The first is to ask a question. The second post comes about six years later saying it's okay to close the thread.

    Regards,
    Jim

Posting Permissions

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