Introduction

Hello, Kotlin Adventurer! Today, we are diving into an essential topic in Kotlin: managing data using collections and data classes. We will apply this concept by building a simple Student Management System. Through this hands-on approach, we will understand how Kotlin's data classes and collections can be effectively used in real-world applications. Ready to embark on this journey? Wonderful, let's get started!

Introducing Methods to Implement

To complete our task, we need to implement three primary methods within our class:

  1. addStudent(name: String, grade: Int): Unit: This method adds a new student and their grade to our list. If the student is already on the list, their grade will be updated.
  2. getGrade(name: String): Int?: This method retrieves the grade for a student by their name. If the student is not found, it returns null.
  3. removeStudent(name: String): Boolean: This method removes a student from the list by their name. It returns true if the student was successfully removed and false if the student does not exist.

Does that sound clear? Awesome, let’s break it down step-by-step.

Implementing the Solution Step-by-Step

Let's begin by defining our StudentManager class, which will use a of data class instances to manage students and their grades.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal