SJSU/Udacity CS046

Lesson 3 - Classes

  1. Introduction
  2. Introducing Ayna
  3. Our First Class
  4. Quiz: Which Are Mutators?
  5. Quiz: The Public Interface of the Person Class
  6. Quiz: Unfriend a Friend
  7. Quiz: Listing Friends
  8. Instance Variables
  9. Quiz: Instance Variables
  10. Quiz: Friends Instance Variable
  11. Quiz: addGas Method
  12. Visualizing the Car
  13. Quiz: addFriend Method
  14. Quiz: unfriend Method
  15. Additional Car Methods
  16. Quiz: Figuring Things Out on a Piece of Paper
  17. Local and Instance Variables, Part 1
  18. Local and Instance Variables, Part 2
  19. Quiz: Constructors
  20. Using Car Constructors
  21. Quiz: Person Constructor
  22. Checking the Person Class
  23. Quiz: Implementing the getFriends Method
  24. Quiz: Seeing People
  25. Quiz: Seeing Connections
  26. Quiz: Do We Have Enough Information?
  27. Quiz: Find the Coordinates of the Endpoint
  28. Update the Person Class
  29. Commenting the Public Interface, Part 1
  30. Commenting the Public Interface, Part 2
  31. Quiz: Improving the Documentation
  32. Why It's Important to Document Your Code
  33. Tracing Objects
  34. Finding Bugs with Tracing, Part 1
  35. Finding Bugs with Tracing, Part 2
  36. More Finding Bugs With Tracing
  37. Find the Error
  38. How Ayna Deals With Errors in Her Code
  39. The this Reference
  40. Another Way to Think About this
  41. Quiz: Trying Out the this Reference
  42. Use this to Make Method Calls
  43. Quiz: Change the Method to Use this
  44. Why It's Important to Learn Programming

Quiz: addFriend Method

Complete the addFriend(Person friend) method! Add the name of the new friend and a space to the instance variable that stores the person's friends. If you don't get the answer after a couple of tries, just click the “Show next step” button. friends = friends + friend.name + " "; This was pretty difficult, and there may be other ways that we didn't think about. Don't worry if you didn't get this answer. Watch the answer video for a detailed explanation.

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =