← Back

Code Challenge 5.2 - Student Class


Objective

Your task is to design and implement a Student class and write a program that tests the class. This challenge will focus on encapsulating object-oriented programming concepts such as constructors, methods, and fields.

Skills to Practice

Challenge Tasks

  1. Create a console project named Challenge 5-2.
  2. Draw the UML Diagram:
    • Draw the UML diagram for the Student class, including fields, constructors, and methods.
  3. Class Implementation:
    • Define a class named Student with the following specifications:
      • Two string data fields named name and id.
      • A constructor that initializes the fields.
      • A method named GetDetails()* that returns the student’s name and id.
  4. Test Program:
    • Write a test program that creates two Student objects:
      • One with name “Alice” and id “A123”.
      • Another with name “Bob” and id “B456”.
    • Display the name and id of each student in this order.

* Use the naming convention that matches your programming language/preference.