Practise object-oriented reasoning, one small step at a time
SC2002 · Object-Oriented Programming and Design · Tutorial 2
Two short practices for Tutorial 2. Work through a sequence of small tasks — read a class diagram, declare state, write a constructor, and coordinate objects from an application class — with checks and hints at every step. No account needed; your progress stays in this browser.
You'll practise
- Private state vs. public behaviour
- Constructors and valid initial state
- Accessors, mutators, and computed values
- Independent objects of the same class
- Coordinating objects from an application class
- Handling invalid input gracefully
Circle
Model a circle as an object with private state, a class constant, a constructor, accessors and mutators, and computed behaviour. Coordinate the object from a small application class.
Dice
Model a single die as an object with a bounded random state, then coordinate two independent dice from an application class that computes their total.
Running a code step actually compiles and runs your Java in a sandboxed server environment, alongside the usual checks. See About for details.