Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 10-14-2005, 05:25 PM   #1 (permalink)
 
Newb Techie

Join Date: Oct 2005

Posts: 4

lizalaz

Default Java Inheritance program

please look at it if you can help:

the Employee example in the bellow, you need to write a program that maintains a list of contacts. There are two types of contact, one is business contacts and the other is friend contacts. For business contacts, in addition to their usual contact information, I will list their business title. For the friends, I will list their birth data.
In the program, you need to define four classes.
1. abstract Contact class that has instant fields such as name, phoneNumber, and emailAddr. You should have default and standard constructors, setter and getter methods.
2. BizContact class that extends the Contact class and has its own instant field called title. You should have default and standard constructors, setter and gettter methods.
3. BuddyContact class that extends the Contact class and has its own instant field called BoD (data of Birth). You should have default and standard constructors, setter and gettter methods.
4. ContactBook class that defines three BizContacts andfour BuddyContacts. You print out all their information afterwards that includes name, phone, email, tiltle to Bod. Remember, even you have limited number of contacts, you still need to use loop to do the job.


(how can i finish the program by above guideline.)


public class Employee {
protected String name;
protected int age;
protected char gender;
protected String SSN;
protected double salary;

public Employee(String name, int age, char gender, String SSN, double salary){
this.name = name;
this.age = age;
this.gender = gender;
this.SSN = SSN;
this.salary = salary;
}

public String getName(){
return name;
}

public int getAge(){
return age;
}

public char getGender(){
return gender;
}

public String getSSN(){
return SSN;
}


}
lizalaz is offline  
Old 10-14-2005, 05:47 PM   #2 (permalink)
 
Newb Techie

Join Date: Nov 2004

Posts: 6

billgrande

Default

It looks like it's basically already done for you, just create the class contact similar to what you have. Then just create classes that extend contact ie class bizContact extends contact. That's pretty much it.

Any specific questions?
billgrande is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On