File tree Expand file tree Collapse file tree
exceptions/chapter-example/temperature-example/src/main/java/org/launchcode Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,14 @@ public void setFahrenheit(double aFahrenheit) {
1212 double absoluteZeroFahrenheit = -459.67 ;
1313
1414 if (aFahrenheit < absoluteZeroFahrenheit ) {
15- System .out .println ("Value is below absolute zero" );
15+ try {
16+ throw new TemperatureException ("That temperature is too low!" );
17+ } catch (TemperatureException e ) {
18+ e .printStackTrace ();
19+ return ;
20+ }
1621 }
17-
1822 fahrenheit = aFahrenheit ;
19- }
23+ System .out .println ("Value is below absolute zero" );
24+ }
2025}
Original file line number Diff line number Diff line change 11package org .launchcode ;
22
3- public class TemperatureException {
4- // Write code here!
5- }
3+ public class TemperatureException extends Exception {
4+ public TemperatureException (String message ){
5+ super (message );
6+ }}
You can’t perform that action at this time.
0 commit comments