← Unit 3 · all exercises
Saved in this browser only

Two ways to build it

Write a Temperature class with two constructors: one taking a value in degrees, and one taking nothing that starts at 20. getDegrees returns the value.

class Temperature { Temperature(); Temperature(int degrees); int getDegrees(); }

Temperature.java
Loading editor…
Results

Examples

  • new Temperature().getDegrees() → 20
  • new Temperature(35).getDegrees() → 35

There are also 3 hidden tests you can't see. Solve the problem, not the examples.