Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // the original code for class Thermometer
- public int measure() {
- if (onoff == false) {
- try {
- throw IllegalStateException(" ");
- } catch (Exception ex) {
- Logger.getLogger(Thermometer.class.getName()).log(Level.SEVERE, null, ex);
- }
- } else {
- Random randoms = new Random();
- random = randoms.nextInt(61) - 30;
- return random;
- }
- return random;
- }
- // my suggestion
- public int measure() {
- if (onoff) {
- return (int) (-30 + Math.random() * 60);
- }
- throw new IllegalStateException();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement