Can't resolve methods in Java class for Temperature Driver -
***i'm having issues creating add() subtract() , divide() method, maybe i'm overthinking it. how return needed object. ide saying "cannot resolve symbol temperature". calling 'this' correctly?
***i aware add , divide methods incomplete, if can receive on completing subtract() method should fall place.
import javax.naming.stringrefaddr; /** * created makoto on 2/4/2016. */ public class temperature { public double temp; public char type; temperature() { temp = 0.0; type = 'o'; } temperature( double temperature, char temptype){ temperature = temp; temptype = type; } public temperature tofahrenheit() { type.equalsignorecase(); switch (type) { case 'c': break; case 'k': break; default: system.out.println("can not convert."); break; } return this.temperature; } public temperature tocelsius() { type.equalsignorecase(); switch (type) { case 'f': break; case 'k': break; default: system.out.println("can not convert."); break; } return this.temperature; } public temperature tokelvin() { type.equalsignorecase(); switch (type) { case 'c': break; case 'f': break; default: system.out.println("can not convert."); break; } return this.temperature; } public temperature add(temperature x){ this.temperature + x; return this.temperature; } public temperature subtract(temperature x){ this.temperature = this.temp - x.temp; return this.temperature; } public temperature divide(int x){ this.temperature = /x; return this.temperature; } }
you need return only.
import javax.naming.stringrefaddr; /** * created makoto on 2/4/2016. */ public class temperature { public double temp; public char type; temperature() { temp = 0.0; type = 'o'; } temperature( double temperature, char temptype){ temperature = temp; temptype = type; } public temperature tofahrenheit() { type.equalsignorecase(); switch (type) { case 'c': break; case 'k': break; default: system.out.println("can not convert."); break; } return this; } public temperature tocelsius() { type.equalsignorecase(); switch (type) { case 'f': break; case 'k': break; default: system.out.println("can not convert."); break; } return this; } public temperature tokelvin() { type.equalsignorecase(); switch (type) { case 'c': break; case 'f': break; default: system.out.println("can not convert."); break; } return this; } public temperature add(temperature x){ this.temp + x.temp; return this; } public temperature subtract(temperature x){ this.temp = this.temp - x.temp; return this; } public temperature divide(int x){ this.temp = /x; return this; } }
Comments
Post a Comment