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 aloneShared 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
Each treasure has a value and a level.
The constructor sets both attributes.
Methods allow access to each value.
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
Step 1
Create attributes
Store value and level inside the class.
- 2
Step 2
Write the constructor
Assign the input parameters to the attributes.
- 3
Step 3
Create getValue
Return the value attribute.
- 4
Step 4
Create getLevel
Return the level attribute.
- 5
Step 5
Test the class
Create a Treasure object and print its values.
More to explore
Want a different challenge?
Browse more guided projects, or come back and start this one whenever you are ready.