public class Person { private String personID; private String firstName; private String lastName; private String birthDate; private String address; public Person(){ personID = ""; firstName = ""; lastName = ""; birthDate = ""; address = ""; } public Person(String id, String first, String last, String birth, String add){ setPerson(id,first,last,birth,add); } public void setPerson(String id, String first, String last, String birth, String add){ personID = id; firstName = first; lastName = last; birthDate = birth; address = add; } public String getFirstName(){ return firstName; } public String getLastName(){ return lastName; } public String getBirthdate(){ return birthDate; } public String getAddress(){ return address; } public void print(){ System.out.print("\nPerson ID = " + personID); System.out.print("\nFirst Name = " +firstName); System.out.print("\nLast Name = " +lastName); System.out.print("\nBirth Date = " +birthDate); System.out.print("\nAddress = " +address); } public String toString(){ return personID+" "+firstName+", "+lastName+" "+birthDate+" "+address+" "; } } //Is my string toString method correct? Can you correct some of my mistakes? Thank you
public class Person {
private String personID; private String firstName; private String lastName; private String birthDate; private String address;
public Person(){
personID = ""; firstName = ""; lastName = ""; birthDate = ""; address = "";
}
public Person(String id, String first, String last, String birth, String add){ setPerson(id,first,last,birth,add);
}
public void setPerson(String id, String first, String last, String birth, String add){
personID = id; firstName = first; lastName = last; birthDate = birth; address = add;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String getBirthdate(){
return birthDate;
}
public String getAddress(){ return address;
}
public void print(){
System.out.print("\nPerson ID = " + personID);
System.out.print("\nFirst Name = " +firstName);
System.out.print("\nLast Name = " +lastName);
System.out.print("\nBirth Date = " +birthDate); System.out.print("\nAddress = " +address);
}
public String toString(){ return personID+" "+firstName+", "+lastName+" "+birthDate+" "+address+" "; }
}
//Is my string toString method correct? Can you correct some of my mistakes? Thank you
Trending now
This is a popular solution!
Step by step
Solved in 2 steps