Start building now

Choose how you want to begin this project.

Open it privately for practice or create a shared workspace to build it together.

No setup required • Guided steps inside the editor

Private practice

Open a private editor and work through the steps at your own pace.

Start project alone

Shared workspace

Create a live session so you can teach, pair, or build the project together.

What you'll build

A Treasure class that stores item value and level (e.g. bronze, silver, gold).

What you'll learn

  • How to define classes properly
  • How constructors assign values
  • How to return attributes with methods
  • How to structure object-based programs

How it works

1

Each treasure has a value and a level.

2

The constructor sets both attributes.

3

Methods allow access to each value.

4

Objects can be created and reused in a program.

Build path

These steps appear inside the editor so you can build one part at a time.

  1. 1

    Step 1

    Create attributes

    Store value and level inside the class.

    Complete in the editorHint available
  2. 2

    Step 2

    Write the constructor

    Assign the input parameters to the attributes.

    Complete in the editorHint available
  3. 3

    Step 3

    Create getValue

    Return the value attribute.

    Complete in the editorHint available
  4. 4

    Step 4

    Create getLevel

    Return the level attribute.

    Complete in the editorHint available
  5. 5

    Step 5

    Test the class

    Create a Treasure object and print its values.

    Complete in the editorHint available

More to explore

Browse more guided projects, or come back and start this one whenever you are ready.