Still can not call my Subclass method returns. J2EE
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 69

Thread: Still can not call my Subclass method returns. J2EE

Threaded View

  1. #1
    Join Date
    Dec 2013
    Posts
    46

    Still can not call my Subclass method returns. J2EE

    I am having problems returning and using my subclass method returns... I am trying to print out the results but am getting just the space allocation only. Any help will greatly appreciated.

    Code:
    package contacts;
    
    
    import java.util.Scanner;
    import java.util.ArrayList;
    
    
    public class Contacts {
    
       
        public static void main(String[] args) 
        {
             
            System.out.println("By enetering B for Business  or P for personal contact: ");
            
            System.out.println("Are you a Business Contact or Personal Contact?: ");
            
            //Storing the users input
            Scanner in = new Scanner(System.in);
            String cont = in.next();      
            
            if (cont.equals("P"))
            {
                System.out.println("Please enter: ");
                        
            }
            
            else if (cont.equals("B"))
            {
              
               
                 Business fno = new Business();
                 Business lno = new Business();
                 Business ado =  new Business();
                 Business pno = new Business();
                 Business emo = new Business();
                 Business jto = new Business();
                 Business orgo = new Business();
                 
                 
                fno.firstName();
                lno.lastName();
                ado.address();
                pno.phoneNumber();
                emo.eMail();
                jto.jobTitle();
                orgo.organization();     
                 
            }
            
            else
            {
                System.out.println("Please choose either B for Business Contact or "
                        + "P as a Personal Contact as you picked an invalid entry.");
               // return;
            }
        }
       
            }
    Code:
    package contacts;
    
    abstract public class ContactInfo 
    {
        public abstract String firstName();
        
        public abstract String lastName();
       
        public abstract String address();
                  
        public abstract String phoneNumber();
       
        public abstract String eMail();      
    }
    Code:
    package contacts;
    
    import java.util.Scanner;
    
    
    public class Business extends ContactInfo 
    {
       
        Scanner in = new Scanner(System.in);
       
        public String firstName()
        {
            System.out.println("Please enter your First Name: ");
            String fName2 = in.next();
            return fName2;
        }
        public String lastName()
        {
            System.out.println("Please enter your Last Name: ");
            String lName2 = in.next();
            return lName2;
        }
        public String address()
        {
            System.out.println("Please enter your Address: ");
            String addre2 = in.next();
            return addre2;
        }
        public String phoneNumber()
        {
            System.out.println("Please enter Phone Number: ");
            String phoneNum2 = in.next();
            return phoneNum2;
        }
        public String eMail()
        {
            System.out.println("Please enter your Email Address: ");
            String eMailAdd2 = in.next();
            return eMailAdd2;
        }
    
     
     
        
       
        public String jobTitle()
        {
            System.out.println("Please enter your job title: ");
            String jobTit = in.next();
            return jobTit;
        }
        public String organization()
        {
            System.out.println("Please enter your organization: ");
            String organ = in.next();
            return organ;
        }
       
       
    }
    Last edited by BigDadd215; February 28th, 2014 at 04:29 AM.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center