1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * All features of CoreFeatures here.
  3. *
  4. * @author (David Thornley)
  5. * @version (0.1)
  6. */
  7. import java.util.Scanner;
  8. public class CoreFeatures
  9. {
  10. // instance variables - replace the example below with your own
  11. private Console console = new Console();
  12. /**
  13. * Constructor for objects of class CoreFeatures
  14. */
  15. public CoreFeatures(Console c)
  16. {
  17. console = c;
  18. }
  19. public double add(double b) {
  20. return console.changeCurrentValue(console.getCurrentValue() + b);
  21. }
  22. public double subtract(double b) {
  23. return console.changeCurrentValue(console.getCurrentValue() - b);
  24. }
  25. public double multiply(double b) {
  26. return console.changeCurrentValue(console.getCurrentValue() * b);
  27. }
  28. public double divide(double b) {
  29. if ( b != 0){
  30. return console.changeCurrentValue(console.getCurrentValue() / b);
  31. }else {console.println("Cannot Divide by 0, Please Try Another Number.");
  32. }
  33. return console.getCurrentValue();
  34. }
  35. public double square() {
  36. return console.changeCurrentValue( Math.pow(console.currentValue, 2));
  37. }
  38. public double squareRoot() {
  39. return console.changeCurrentValue( Math.sqrt(console.currentValue));
  40. }
  41. public double inverse() {
  42. return console.changeCurrentValue( (1/console.currentValue));
  43. }
  44. public double changeSign() {
  45. return console.changeCurrentValue((console.currentValue *= -1));
  46. }
  47. public double variableExponentiation(double b) {
  48. return console.changeCurrentValue(Math.pow(console.currentValue,b));
  49. }
  50. }