Code Lab

Ball

EasyClasses3 min

Write a class Ball. Its constructor takes the ball type and stores it in the field ballType. If no type is given, the ball gets the type 'regular'.

Examples

new Ball().ballType

Returns 'regular'

new Ball('super').ballType

Returns 'super'

Source

Loading the editor...
  1. No argument gives a regular ball
  2. The type comes from the argument

Hidden tests run on Submit.