Hi all , I don't understand how to handle the homework on the java
interface and abstract class
I have , and I just don't know how to let my Person call the
MyOwnInterface, please help!
Thank You!
>>>>>>>>>>>>>>>>>>>>
public class Address implements AddressInterface {
int streetNumber;
String streetName;
String country;
public Address() {
}
public Address(int streetNumber, String streetName, String
country) {
this.streetNumber = streetNumber;
this.streetName = streetName;
this.country = country;
}
public int getStreetNumber() {
return streetNumber;
}
public void setStreetNumber(int streetNumber) {
this.streetNumber = streetNumber;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<
public interface AddressInterface {
int getStreetNumber();
void setStreetNumber(int streetNumber);
String getStreetName();
void setStreetName(String streetName);
String getCountry();
void setCountry(String country);
}
<<<<<<<<<<<<<<<<<<<<<<
public interface MyOwnInterface {
AddressInterface getAddress();
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
public class Person implements PersonInterface,MyOwnInterface
{
int cashSaving;
int retirementFund;
String firstName;
String lastName;
// Constructor with arguments
Person(int cashSaving,
int retirementFund,
String firstName,
String lastName){
this.cashSaving = cashSaving;
this.retirementFund = retirementFund;
this.firstName = firstName;
this.lastName = lastName;
}
// Compute person's total wealth
public int computeTotalWealth(){
System.out.println((cashSaving + retirementFund));;
return (cashSaving + retirementFund);
}
// Get person's name
public String getName(){
return firstName + " " + lastName;
}
// Implement method of AddressInterface
}
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en