Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

need help!! How to use super in equals() method and makeCopy() method?

807589Aug 16 2008 — edited Aug 23 2008
This is my Name class:
class Name {

    private String title;
    private String name;
    
    public Name(){
    	title=" ";
    	name=" ";
    }
    
    public Name(String title){
    	setTitle(title);
    	name=" ";
    }
    
    public Name(String title,String name){
    	setTitle(title);
    	setName(name);
    }
    
    public void setTitle(String title){
    	this.title=title;
    }
    public String getTitle(){
    	return title;
    }
    
    public void setName(String name){
    	this.name=name;
    }
    public String getName(){
    	return name;
    }   
This is my Person Class
class Person extends Name{

    private String address;
    private String tel;
    private String email;	
 	
    public Person(){
    	super();
    	address=" ";
    	tel=" ";
    	email=" ";
    }
    
    public Person(String name){
    	super(name);
    	address=" ";
    	tel=" ";
    	email=" ";
    }
    
    public Person(String title,String name,String addressStr){
    	super(title,name);
    	setAddress(addressStr);
    	tel=" ";
    	email=" ";
    }
    
    public Person(String title,String name,String addressStr,String phoneNum){
    	super(title,name);
    	setAddress(addressStr);
    	setTel(phoneNum);
    	email=" ";
    }
    
    public Person(String title,String name,String addressStr,String phoneNum,String emailStr){
    	super(title,name);
    	setAddress(addressStr);
    	setTel(phoneNum);
    	setEmail(emailStr);
    }
    
    public void setAddress(String add){
    	address=add;
    }
    public String getAddress(){
    	return address;
    }
    
    public void setTel(String telephone){
    	tel=telephone;
    }
    public String getTel(){
    	return tel;
    }
    
    public void setEmail(String emailAdd){
    	email=emailAdd;
    }
    public String getEmail(){
    	return email;
    }
     
 	public boolean equals(Person inputRecords){
    	boolean equalOrNot=false;
    	if(inputRecords.super(getTitle()).equals(title))         //this is wrong
    		if(inputRecords.super(getName()).equals(name))           //this is wrong
    			if(inputRecords.getAddress().equals(address))
    				if(inputRecords.getTel().equals(tel))
    					if(inputRecords.getEmail().equals(email))
    						equalOrNot=true;
    	return equalOrNot;    
   	}
   	
   	public void makeCopy(Person copyInto){
   		copyInto.super(setTitle(title));             //this is wrong
   		copyInto.super(setName(name));           //this is wrong
   		copyInto.setAddress(address);
   		copyInto.setTel(tel);
   		copyInto.setEmail(email);
   	}
}
How can I correct the wrong part?
I don't understand how to use super in equals() method and makeCopy() method.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2008
Added on Aug 16 2008
8 comments
100 views