
/*
 * File: FacePamphletProfile.java
 * ------------------------------
 * This class keeps track of all the information for one profile
 * in the FacePamphlet social network.  Each profile contains a
 * name, an image (which may not always be set), a status (what
 * the person is currently doing, which may not always be set),
 * and a list of friends.
 */

import java.util.Iterator;

import acm.graphics.GImage;

public class FacePamphletProfile implements FacePamphletConstants {

    /**
     * Constructor This method takes care of any initialization needed for the
     * profile.
     */
    public FacePamphletProfile(String name) {
        // You fill this in
    }

    /** This method returns the name associated with the profile. */
    public String getName() {
        // You fill this in. Currently always returns the empty string.
        return "";
    }

    /**
     * This method returns the image associated with the profile. If there is no
     * image associated with the profile, the method returns null.
     */
    public GImage getImage() {
        // You fill this in. Currently always returns null.
        return null;
    }

    /** This method sets the image associated with the profile. */
    public void setImage(GImage image) {
        // You fill this in
    }

    /**
     * This method returns the status associated with the profile. If there is
     * no status associated with the profile, the method returns the empty
     * string ("").
     */
    public String getStatus() {
        // You fill this in. Currently always returns the empty string.
        return "";
    }

    /** This method sets the status associated with the profile. */
    public void setStatus(String status) {
        // You fill this in
    }

    /**
     * This method adds the named friend to this profile's list of friends. It
     * returns true if the friend's name was not already in the list of friends
     * for this profile (and the name is added to the list). The method returns
     * false if the given friend name was already in the list of friends for
     * this profile (in which case, the given friend name is not added to the
     * list of friends a second time.)
     */
    public boolean addFriend(String friend) {
        // You fill this in. Currently always returns true.
        return true;
    }

    /**
     * This method removes the named friend from this profile's list of friends.
     * It returns true if the friend's name was in the list of friends for this
     * profile (and the name was removed from the list). The method returns
     * false if the given friend name was not in the list of friends for this
     * profile (in which case, the given friend name could not be removed.)
     */
    public boolean removeFriend(String friend) {
        // You fill this in. Currently always returns false.
        return false;
    }

    /**
     * This method returns an iterator over the list of friends associated with
     * the profile.
     */
    public Iterator<String> getFriends() {
        // You fill this in. Currently always returns null.
        return null;
    }

    /**
     * This method returns a string representation of the profile. This string
     * is of the form: "name (status): list of friends", where name and status
     * are set accordingly and the list of friends is a comma separated list of
     * the names of all of the friends in this profile.
     *
     * For example, in a profile with name "Alice" whose status is "coding" and
     * who has friends Don, Chelsea, and Bob, this method would return the
     * string: "Alice (coding): Don, Chelsea, Bob"
     */
    @Override
    public String toString() {
        // You fill this in. Currently always returns the empty string.
        return "";
    }

}

@@ -385,119 +385,328 @@
 til.
-Iterator;%0D%0A%0D%0Aimport acm.graphics.GImage;%0D%0A%0D%0Apublic class FacePamphletProfile implements FacePamphletConstants %7B
+ArrayList;%0D%0Aimport java.util.Iterator;%0D%0Aimport java.util.List;%0D%0A%0D%0Aimport javafx.scene.image.Image;%0D%0A%0D%0Apublic class FacePamphletProfile implements FacePamphletConstants %7B%0D%0A    private List%3CString%3E friends = new ArrayList%3CString%3E();%0D%0A    private Image image;%0D%0A    private String name = %22%22;%0D%0A    private String status = %22%22;
 %0D%0A%0D%0A
@@ -875,35 +875,33 @@
         
-// You fill this in
+this.name = name;
 %0D%0A    %7D%0D
@@ -1016,90 +1016,19 @@
     
-// You fill this in. Currently always returns the empty string.%0D%0A        return %22%22
+return name
 ;%0D%0A 
@@ -1214,17 +1214,16 @@
  public 
-G
 Image ge
@@ -1246,80 +1246,20 @@
     
-// You fill this in. Currently always returns null.%0D%0A        return null
+return image
 ;%0D%0A 
@@ -1363,9 +1363,8 @@
 age(
-G
 Imag
@@ -1383,35 +1383,35 @@
         
-// You fill this in
+this.image = image;
 %0D%0A    %7D%0D
@@ -1653,90 +1653,21 @@
     
-// You fill this in. Currently always returns the empty string.%0D%0A        return %22%22
+return status
 ;%0D%0A 
@@ -1795,35 +1795,37 @@
         
-// You fill this in
+this.status = status;
 %0D%0A    %7D%0D
@@ -2343,61 +2343,126 @@
     
-// You fill this in. Currently always returns true.%0D%0A
+if (friends.contains(friend)) %7B%0D%0A            return false;%0D%0A%0D%0A        %7D else %7B%0D%0A            friends.add(friend);%0D%0A    
     
@@ -2475,24 +2475,35 @@
 turn true;%0D%0A
+        %7D%0D%0A
     %7D%0D%0A%0D%0A   
@@ -2975,62 +2975,128 @@
     
-// You fill this in. Currently always returns false.%0D%0A
+if (friends.contains(friend)) %7B%0D%0A            friends.remove(friend);%0D%0A            return true;%0D%0A%0D%0A        %7D else %7B%0D%0A    
     
@@ -3110,24 +3110,35 @@
 urn false;%0D%0A
+        %7D%0D%0A
     %7D%0D%0A%0D%0A   
@@ -3310,80 +3310,33 @@
     
-// You fill this in. Currently always returns null.%0D%0A        return null
+return friends.iterator()
 ;%0D%0A 
@@ -3935,90 +3935,85 @@
     
-// You fill this in. Currently always returns the empty string.%0D%0A        return %22%22
+return String.format(%22%25s (%25s): %25s%22, name, status, String.join(%22, %22, friends))
 ;%0D%0A 

Finish assignment 7 milestone 2