CS106A Assignment 7 – FacePamphlet

The URS.


  • 9 days to program
  • Keep track of a simple social network allowing addition, deletion and lookup of members

Data to store:

  • name
  • image (optional)
  • status (optional)
  • friends list

Program Setup

Milestone 1: Assemble the GUI interactors

As per NameSurfer, this was very simple and took 20 minutes max.



Hang on.  I missed bit of making sure nothing happened if the boxes were blank.  That took a little longer to suss out.  Checking enteredName == “” did not call the correct bit of code, but checking == 0, called the error checking code.  If this were a fully fledged program I’d want to code it to ensure no blank (any number of spaces) could be used a a name and only text strings of alphabetical characters was deemed to be a valid input.

Milestone 2: Implement the FacePamphletProfile Class

I managed to get this working ok, though later, the two strings seemed to pull the name out of the profile, but not status or friends and friends could be added when the entered name did not exist in the db (so clearly something was up).

Bug hunting found a “}” too early in one of the action checkers.  That seemed to take care of the ability to add friends too soon and also a bug where the class would report a profile deleted when it was not.  My toString method kept returning null. That needed Milestone 4 completion again!

Milestone 3: Implement the FacePamphletDatabase Class

I coded this at the same time as the Milestone 2 class and I followed a youtube video so I guess I cheated (though I did have a bunch of bugs to fix, so following tutorials when you do not fully understand what you are doing is not much of a help. Sorting out the bugs is where I seem to learn how the code works).

Milestone 4: Implement functionality for Change, Status, Change Picture and Add Friends buttons

What tripped me up here was trying to add info to the various data handler’s I’d set up rather than the “displayedProfile” I more recently set up.   Early on the code was only adding friends to the displayed profile, not all linked profiles (so at the time of writing, presumably some code was needed to scan the data structures and add a reciprocal friend (which I can actually picture so off to coding again).  From there, it seemed fairly simple to code the program without peeking at others’ solutions.

What I’m not fully understanding is how “private FacePamphletProfile displayedProfile;” functions. I’ve not declared it as a array or map, and it seems to store data.  If I get around to adding the extension to save data between program runs, then I’ll probably figure out how this works (assuming it does not involve a rewrite of my data handling code, which if it was written competently would not be needed).

Overall, this was pretty easy to set up.

CS106A Assignment 7 - Milestone 4 Completed

CS106A Assignment 7 – Milestone 4 Completed

Milestone 5: Implement the FacePamphletCanvas class and complete the implementation of the FacePamphletProfile Class

First up I set up the displayProfile method to draw things to screen as required (with the exception of the GImage):



Adding the guts of the code was pretty straight forward.  The only thing that took some reading was an iterator for drawing the list of friends to screen.

Creating the Program Including Beta Testing

  • Coding began 22/06/2017.  I lost my coding when I thought I backed it up before restoring the starter files.  Started again on 27/06/2017.
  • Coding ended 04/07/2017
  • Total calendar days:  12 days (7 if I get to restart the clock after deleting my files).  9 days was the target.
  • Ha, after thinking I’d finished, another day of debugging which introduced new bugs here and there which needed swatting.  When I added a friend, then the status would update to be “bla bla is”, as opposed to “no current status’.  The friend code does not touch the status code!   This bug was hard to find.  I decided to lay some of the messier bits of code out in separate methods so I could comment out a single call to say “set status()”. Quite frustratingly, when I added a checker code to the friends method, it ran and the status did not update (the only thing the code did was display that “status should not update” in the console.  I removed the code and the program worked as it should.  Hmmmm.

The Shipped Program

The final program (with some test cross hairs)

The final program (with some test cross hairs)

Packaged Jar file.  Extract zipped contents and run the facePamphlet.jar file if you have java installed on your system.

Available photos.  Feel free to add your own:

  • me.png
  • female.jpg
  • army.gif

Program Modifications / Extensions

  • Save the state of the social network so it is persistent between program executions.  I worked out how to save files as a side project.
  • Add some additional information to track (make some stuff up).
  • Add thumbnail of friend to friend list.
  • Make into a responsive interface for screen size changes. Tried this.  Seems the e event could not hack it.
  • List all the members of the network.


A lot less peeking at other’s code here.  For the last bit (the friends iterator), the help here: http://beginnersbook.com/2014/07/java-hashmap-iterator-example/ finished the assignment.

Lessons Learned

More knowledge of data handling, mostly in the form of iterators.  I’m still hazy on how the photo is tracked as there’s not specific list created for it as far as I can tell.

Just when you think things are over and a final run through the program is made, bugs show up.