Menu
Coddy logo textTech

Recap challenge #2

Lesson 7 of 12 in Coddy's Basics of Classes and Objects in C# course.

challenge icon

Challenge

Easy

Write a class Person with,

Attributes (must be public) -

  • name (string)
  • age (integer)

Constructor that gets as input two arguments and sets them accordingly to name and age attributes.

Methods -

  • celebrateBirthday that gets no input and increases the age by one.
  • changeName that gets as input a string and changes the current name with the given input.

Try it yourself

// Write code here

All lessons in Basics of Classes and Objects in C#