public class PersonDemo
{
public static void main(String[] args)
{
Person sara = new Person("Sara", "sara.jpg", 10, 200);
Person chenghan = new Person("Cheng-Han", "cheng-han.png", 300, 0);
Person cay = new Person("Cay", "cay.gif", 250, 180);
}
}
public class Person
{
private String name;
private String friends;
public Person (String aName, String pictureName, int xCoord, int yCoord)
{
name = aName;
friends = "";
Picture picture = new Picture(pictureName);
picture.translate(xCoord, yCoord);
picture.draw();
}
public void addFriend(Person friend)
{
friends = friends + friend.name + " ";
}
public void unfriend(Person nonFriend)
{
friends = friends.replace(nonFriend.name + " ", "");
}
public String getFriends()
{
return friends;
}
}