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

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.

Try something like this ...
public boolean equals(Object other) {
  if (other==null || !(other instanceof Person)) return false;
  Person that = (Person) other;
  return getTitle().equals(that.getTitle())
      && getName().equals(that.getName())
      && getAddress().equals(that.getAddress())
      && getTel().equals(that.getTel())
      && getEmail().equals(that.getEmail())
Notes:
* This overrides Object's public boolean equals(Object other), which is (probably) what you meant.
* You don't need to call "super.getWhatever" explicitly... just call "getWhatever" and let java workout where it's defined... this is better because if you then override getTitle() for example you don't need to change your equals method (which you would otherwise probably forget to do, which would probably have some interesting side effects.
Cheers. Keith.

Similar Messages

  • Need help how to use itunes card to download music

    Need help how to use itunes card to download music

    If you want to add the iTunes card to your account, then in the iTunes app on the iPad you should be able to scroll to the bottom of the Music tab and there should be a Redeem button - there is more info here : http://support.apple.com/kb/HT1574

  • Need help: how to use "FileLock"

    Hi,
    I would like to be able to read the file at any time, but when
    write is acquired (assuming the lock is released), no read is allowed
    until the lock for the write is released.
    How to use FileLock to accomplish this scenario?
    Any input is appreciated.
    Thanks,
    Pin

    I would suppose that the first step would be to determine that the OS you are working on actually supports that...from the java docs...
    Platform dependencies
    Whether or not a lock actually prevents another program from accessing the content of the locked region is system-dependent and therefore unspecified.

  • Need help -how to use a GUI to compile a file

    hello peeps,
    I have this problem, let's get directly into it, i have a program that has GUI with a Text Area that im going to copy a text file into it (using JFileChooser FileReader and readLine() ...) so i have radio buttons like (view, compile and execute) and an OK button to get the selected option, what i want to know is how to compile the file that is in the text area, like how to get to the MS-dos console and javac to start. i hope this description is clear, and i'll be very appreciative for any help!

    thanks for your response, but its not working it keeps on throwing IOException, i tried to put a direct string into it like (Runtime.getRuntime().exec("javac MyClass.java"); and same thing happend. Am i missing something? like is there something to add before calling that line of code? i did import Runtime
    ok here is how my code looks like:
       if(compile.isSelected())
                       try
                       //name of the file im pasting into the text area  
                       String filename = file.getName();
                       Runtime.getRuntime().exec("javac" + filename);
                       catch (IOException e)
                         System.out.println("error compiling program");
                   }

  • I have I pad one use iOS 5.1.1 i want update to iOS 8 itry a lot time but no possible  i need  help how ican doit

    I have I pad one use iOS 5.1.1 i want update to iOS 8 itry a lot time but no possible  i need  help how ican doit.

    The iPad 1 can not be upgraded beyond 5.1.1.

  • Hii i need help i cannot use my apple id for download on app store because they say i need to verify my account but i don't know how so please somebody can help me? i try to resset my password but that don't help

    hii i need help i cannot use my apple id for download on app store because they say i need to verify my account but i don't know how so please somebody can help me? i try to resset my password but that don't help

    is it asking for ur security questions?

  • Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    The Mac OS X and iOS versions are separate products

  • Mail server not responding. Need help how to verify my account

    Mail server not responding. Need help how to verify my account

    There are instructions on this page for how to create a new account without giving credit card details (the instructions won't work with existing accounts) : http://support.apple.com/kb/HT2534
    Unless an account is created via those instructions then credit card details will need to be entered on it before the account can be used.

  • I need help, How could I add Aliases to Local Administrator account via terminal commands???

    I need help, How could I add Aliases to Local Administrator account via terminal commands???
    I want to use commands to add alias for existing administrator account remotly by using ARD.
    Thanks.

    Hi,
    a Windows Domain Controller does not have any local user or groups. So you might add the user to the admin group at Domain level.
    B RGDS,
    Gregor
    Edited by: Gregor Gasper on Jan 9, 2009 1:44 PM

  • Need Help with Formula using SQL maybe

    I need help!  I work with Crystal reports XI and usually manage just fine with the Formula editor but his one I think will require some SQL and I am not good at that.
    We are running SQL 2000 I think (Enterprise Manager 8.0)  Our sales people schedule activities and enter notes for customer accounts.  Each is stored in a separate table.  I need to find activities that are scheduled 240 days into the future and show the most recent note that goes with the account for which that activity is scheduled.
    The two tables, Activities and History, share the an accountID field in common that links them to the correct customer account.   I want to look at dates in the Startdate.Activities field more than 240 days in the future and show the most recent note from the History table where the accountid's match. I figure my query will contain a join on AccountID.Activities and AccountID.History used with Max(completedate.History) but I do not understand how to word it.
    I would like to perform all this in crystal if possible.  I humbly request your help.
    Membery

    You SQL would look something like this...
    SELECT
    a.AccountID,
    a.BlahBlahBlah, -- Any other fields you want from the Activities table
    h.LastComment
    FROM Activities AS a
    LEFT OUTER JOIN History AS h ON a.AccountID = h.AccountID
    WHERE (a.ActivityDate BETWEEN GetDate() AND DateAdd(dd, 240, GetDate()))
    AND h.HistoryID IN (
         SELECT MAX(HistoryID)
         FROM History
         GROUP BY AccountID)
    This method assumes that the History table has a HistoryID that increments up automatically each time a new comment is added... So a comment made today would always have a higher HistoryID that one made yesterday.
    If I'm wrong and there is no HistoryID or the HistoryID doesn't increment in a chronological fashion, it can still be done but the code is a bit more complex.
    HTH,
    Jason

  • HT201269 hi i need help, i just go a new iPhone 5 and i want to put all my backed up stuff on, but it doesn't show on the list, how do i get all my stuff back and yes i did backup the old phone

    hi i need help, i just go a new iPhone 5 and i want to put all my backed up stuff on, but it doesn't show on the list, how do i get all my stuff back and yes i did backup the old phone

    Follow the explicit instructions in the article from which the thread was started and restore the device from the backup of the previous device.

  • My Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem

    my Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem

    Carlos-
    Start by signing out and back in to see if it will see the subscription: 
    How to sign in and sign out of creative cloud (activate/deactivate)
    If the apps are installed fine and close after launch see this link:
    CC applications close immediately after launch
    If the problem is something different, please let us know the error you see or what is happening on the screen so we can advise  you on a solution
    Pattie

  • Hi, I have this green mark (with pointing arrow looks like a link) on some words show on my window screen when I open a web page, I wonder if it is a virus link or such. Need help how to get rid of it. Thanks

    Hi, I have this green mark (with pointing arrow looks like a link) on some words show on my window screen when I open a web page, I wonder if it is a virus link or such. Need help how to get rid of it. Here's the example:
    WING
    GAMES
    MAJORITY
    Thanks

    If the third link you posted (the link containing the word "majority") does not look like the following then you inadvertently installed adware.
    That particular page should resemble the following:
    The word "majority" in the third paragraph should not be a link and should not have the green icon associated with it.
    To learn how this may have occurred, and how to prevent it from occurring in the future, read How to install adware
    Most so-called "news" websites are nothing more than entertainment outlets that cater to prurient interests, and contain advertisements that leave the user about three clicks away from installing junk. If you decide to frequent those websites, Safari's "Reader" feature helps minimize that exposure.
    Try it:

  • How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    Try asking at ifixit.com. The iPhone is not considered user servicable. You're not going to get much help on an Apple sponsored forum.

  • HT201269 I'm not a tech person, but need help with my Itunes account in transferring money and downloads onto new phone I purchased 2 weeks ago when my Iphone was stolen. I don't know how to get the money or music on new phone?

    Need help with Itunes transferrs and can I use my Edge phone as a router?

    I'm not a tech person, but need help with my Itunes account in transferring money and downloads onto new phone
    Is this an iPhone?
    Set it up using the AppleID you used on the previous iPhone.

Maybe you are looking for

  • Officejet Pro 8600 Premium e-All-in-One - N911n photo paper Not a paper choice for Tray 1

    For the HP Officejet Pro 8600 Premium e-All-in-One - N911n printer I am running Windows 7 64-bit No error Messages New Printer setup I do not see photo paper as a paper choice for in Tray 1 This question was solved. View Solution.

  • IPhone won't exit recovery mode/ keeps saying "connect to iTunes"

    I recently updated my iPhone 6 plus to iOS 8.2 everything was going fine, I was able to download the new iOS. I was updating the phone when suddenly iTunes informed me that I had to restore the phone in order for it to be updated. I gladly did. And t

  • Uninstalling Trial CS3 products

    I need to remove some trial versions of Adobe CS3. How do I go about doing that. I don't think I'm suppose to just delete the application folder, am I? Please help!

  • Set the value of a shared secret in a custom auth class

    Hello All, We are trying to use a custom authentication class to gain additional parameter to pass along in a SAML assertion to a third party vendor. We have successfully added the new custom auth class, but we are unable to determine how to assign t

  • Can't get to imovie slow motion...

    hi so i understand that in this version of imovie you're meant to double click a clip in order to bring up the "inspector" that can allow me to speed up/slow down clips etc. but, when i double click, all the clip does is play. forgive me for being in