BuddyInfo - return this.age; } public void setAge(int age){...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.Serializable; i public class BuddyInfo implements Serializable{ p private static final long serialVersionUID = 1L; String name, address, phoneNumber; int age; i public BuddyInfo(){ this("","","",0); } public BuddyInfo(String name, String address, String phoneNumber, int age){ this.name = name; this.address = address; this.phoneNumber = phoneNumber; this.age = age; } public BuddyInfo(BuddyInfo bi){ this.name = bi.getName(); this.address = bi.getAddress(); this.phoneNumber = bi.getPhoneNumber(); this.age = bi.getAge(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public int getAge(){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return this.age; } public void setAge(int age){ this.age = age; } public boolean isOver18(){ return this.age >= 18; } public String greeting(){ return "Hello World!"; } @Override public String toString(){ String s = ""; s += name + "\n"; s += address + "\n"; s += phoneNumber + "\n"; return s; } @Override public boolean equals(Object o){ if(o instanceof BuddyInfo){ BuddyInfo bi = (BuddyInfo)o; return ((this.name.equals(bi.getName()))&& (this.address.equals(bi.getAddress()))&& (this.phoneNumber.equals(bi.getPhoneNumber()))&& (this.age==bi.getAge())); } return false; } public String toXML(){ String s = "\t<BuddyInfo "; s += "name=\"" + this.name + "\" "; s += "address=\"" + this.address + "\" "; s += "phone=\"" + this.phoneNumber + "\" "; s += "age=\"" + this.age + "\">"; return s + "</BuddyInfo>\n"; } }...
View Full Document

Page1 / 2

BuddyInfo - return this.age; } public void setAge(int age){...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online