Я нахожусь в середине назначения адресной книги.Это выглядит примерно так ...
public class addressBook {
private String businessPhone;
private String cellPhone;
private String facebookID;
private String firstName;
private String homeAddress;
private String homePhone;
private String lastName;
private String middleName;
private String personalWebsite;
private String skypeID;
public addressBook (String fn, String mn, String ln, String homeAddress, String businessPhone, String homePhone,String cellPhone, String facebookID, String personalWebsite, String skypeID) {
firstName = fn;
middleName = mn;
lastName = ln;
this.homeAddress = homeAddress;
this.businessPhone = businessPhone;
this.homePhone = homePhone;
this.cellPhone = cellPhone;
this.facebookID = facebookID;
this.personalWebsite = personalWebsite;
this.skypeID = skypeID;
}
public addressBook(String fn) {
this(fn,"","","","","","","","","");
}
public addressBook(String fn, String mn) {
this(fn,mn,"","","","","","","","");
}
public addressBook(String fn, String mn, String ln) {
this(fn,mn,ln,"","","","","","","");
}
}
//A bunch of Setter and Getter methods here for each
Я позже создал расширенный класс
public class BanffMarathonRunner extends addressBook{
private int time;
private int years;
public BanffMarathonRunner(String fn, String ln, int min, int yr) {
super(fn,"",ln);
this.time=min;
this.years=yr;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
BanffMarathonRunner[] runner = new BanffMarathonRunner[15];
runner[0] = new BanffMarathonRunner("Elena", "Brandon", 341, 1);
runner[1] = new BanffMarathonRunner("Thomas", "Molson", 373, 2);
runner[2] = new BanffMarathonRunner("Hamilton", "Brandon", 278, 5);
runner[3] = new BanffMarathonRunner("Suzie", "Sarandin", 329, 7);
runner[4] = new BanffMarathonRunner("Phillip", "Winne", 445, 9);
runner[5] = new BanffMarathonRunner("Alex", "Trebok ", 275 , 3);
runner[6] = new BanffMarathonRunner("Emma", "Pivoto", 275, 4);
runner[7] = new BanffMarathonRunner("John", "LLenthen",243, 1);
runner[8] = new BanffMarathonRunner("James", "Lean", 334, 1);
runner[9]= new BanffMarathonRunner("Jane", "Ostin", 412, 1);
runner[10] = new BanffMarathonRunner("Emily", "Car", 393, 4);
runner[11] = new BanffMarathonRunner("Daniel", "Hamshire", 299, 4);
runner[12]= new BanffMarathonRunner("Neda", "Bazdar", 343, 3);
runner[13]= new BanffMarathonRunner("Aaron", "Smith", 317, 6);
runner[14] = new BanffMarathonRunner("Kate", "Hen", 341, 8);
System.out.println(runner[3].getTime());
System.out.println(runner[3].getFirstName());
System.out.println(runner[3].getLastName());
System.out.println(runner[3].getMiddleName());
System.out.println(runner[3].getYear());
//for (BanffMarathonRunner people : runner)
// System.out.println(people.getFirstName() + people.getLastName()+ people.getTime() + people.getYear());
}
public void setTime(int time) {
this.time = time;
}
public void setYear(int years) {
this.years = years;
}
public int getTime() {
return time;
}
public int getYear() {
return years;
}
}
Инструкция system.out для печати фамилии по какой-то причине возвращает пустую строкуа отчество отображает фамилию?Может кто-нибудь сказать мне, почему это происходит?
Спасибо!