KotlinCS 124 LogoJava
PrevIndexNext
Kotlin
Java
  • Implementing a Map : 04/26/2024

  • Streams : 04/25/2024

  • Generics : 04/24/2024

  • Hashing : 04/23/2024

  • Binary Search : 04/22/2024

  • MP3: Course Ratings : 04/19/2024

  • Quicksort : 04/18/2024

  • Merge Sort : 04/17/2024

  • Sorting Algorithms : 04/16/2024

  • MP Debugging Part 1 : 04/15/2024

  • MP2: Course Activity : 04/12/2024

  • Practice with Recursion : 04/11/2024

  • MP Debugging Part 0 : 04/10/2024

  • MP2: API Client : 04/09/2024

  • MP2: API Server : 04/08/2024

  • Trees and Recursion : 04/05/2024

  • Trees : 04/04/2024

  • Recursion : 04/03/2024

  • MP1: Filtering and Search : 04/02/2024

  • MP1: Loading and Sorting : 04/01/2024

  • Lists Review and Performance : 03/29/2024

  • Linked Lists : 03/28/2024

  • Algorithms and Lists : 03/27/2024

  • Continuing MP0 : 03/26/2024

  • Getting Started with MP0 : 03/25/2024

  • Lambda Expressions : 03/22/2024

  • Anonymous Classes : 03/21/2024

  • Practice with Interfaces : 03/20/2024

  • Implementing Interfaces : 03/19/2024

  • Using Interfaces : 03/18/2024

  • Working with Exceptions : 03/08/2024

  • Throwing Exceptions : 03/07/2024

  • Catching Exceptions : 03/06/2024

  • References and Polymorphism : 03/05/2024

  • References : 03/04/2024

  • Data Modeling 2 : 03/01/2024

  • Equality and Object Copying : 02/29/2024

  • Polymorphism : 02/28/2024

  • Inheritance : 02/27/2024

  • Data Modeling 1 : 02/26/2024

  • Static : 02/23/2024

  • Encapsulation : 02/22/2024

  • Constructors : 02/21/2024

  • Objects, Continued : 02/20/2024

  • Introduction to Objects : 02/19/2024

  • Compilation and Type Inference : 02/16/2024

  • Practice with Collections : 02/15/2024

  • Maps and Sets : 02/14/2024

  • Lists and Type Parameters : 02/13/2024

  • Imports and Libraries : 02/12/2024

  • Multidimensional Arrays : 02/09/2024

  • Practice with Strings : 02/08/2024

  • null : 02/07/2024

  • Algorithms and Strings : 02/06/2024

  • Strings : 02/05/2024

  • Functions and Algorithms : 02/02/2024

  • Practice with Functions : 02/01/2024

  • More About Functions : 01/31/2024

  • Errors and Debugging : 01/30/2024

  • Functions : 01/29/2024

  • Practice with Loops and Algorithms : 01/26/2024

  • Algorithms : 01/25/2024

  • Loops : 01/24/2024

  • Arrays : 01/23/2024

  • Compound Conditionals : 01/22/2024

  • Conditional Expressions and Statements : 01/19/2024

  • Operations on Variables : 01/18/2024

  • Variables and Types : 01/17/2024

  • Welcome to CS 124 : 01/16/2024

MP2: Course Activity

To wrap up MP2, we’ll add support for viewing details about a single course to our app. We’ll add a new activity that uses the support for retrieving course information we’ve already added to our API server and client.

MainActivity Course Clicked
MainActivity Course Clicked

As usual, you should be done with previous tests before proceeding. Specifically, you should be passing test0_CourseClassDesign, test1_ServerCourseRoute, and test2_ClientGetCourse. We’ll be using all of that functionality to wrap up MP2!

Our first step is to add the ability to handle clicks on summaries in our summary list. This is where we’ll launch our new CourseActivity, and so we’ll also have a chance to discuss how to launch an activity in Android.

Note that, as described in the walkthrough above, to pass the test case here you need to add a String extra to the Intent with the key “summary” containing the summary that was clicked serialized to JSON. You should use the information and guidance about serialization we’ve provided in past lessons.

CourseActivity UI
CourseActivity UI

We’re almost there! At this point:

  1. Your server can provide course details via the /course/ route
  2. Your client can fetch those details using the getCourse method
  3. Your MainActivity can launch the CourseActivity and pass it details on the course to display

All that’s left is to finish our CourseActivity so that the details about the course are shown! Let’s see how to do that.

When you are done, your CourseActivity should display the title for the course—equivalent to the toString method for the Summary—and the course description. You don’t need two separate UI components to do this, but the two Strings should be separated by whitespace.

For this final bit of MP2 we’re providing a bit less explicit guidance, to give you a chance to spread your wings. You can do it! Refer to the code in the MainActivity for help, since there are great things to mimic there. Ask on the forum or tutoring site when you get stuck. Have fun!

Your Goal Today
Your Goal Today

As a reminder, on lessons where we focus on the machine project we will not assign a homework problem! However, the lesson will usually focus on helping you complete a particular part of the MP test suite, and so we encourage you to spend time on that in lieu of a homework problem.

Right now your goal should be to

  1. modify your MainActivity so that it correctly generates an Intent when a course is clicked, which will pass test3_SummaryClickLaunch
  2. design your CourseActivity class so that it correctly displays the course description using the information provided by the Intent and the getCourse method you completed on your API client, which will pass test4_CourseView
  3. At that point you’ll be done with MP2!

If you get stuck, find us for help on the tutoring site or forum. If you have extra time after today’s lesson, you may want to move on and begin work on the next lesson, which also covers MP1.

MP2 Scores
MP2 Scores