1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- /**
- * All features of CoreFeatures here.
- *
- * @author (David Thornley)
- * @version (0.1)
- */
-
- import java.util.Scanner;
-
- public class CoreFeatures
- {
- // instance variables - replace the example below with your own
-
- private Console console = new Console();
-
- /**
- * Constructor for objects of class CoreFeatures
- */
- public CoreFeatures(Console c)
- {
-
- console = c;
- }
-
-
- public double add(double b) {
-
- return console.changeCurrentValue(console.getCurrentValue() + b);
- }
-
- public double subtract(double b) {
- return console.changeCurrentValue(console.getCurrentValue() - b);
- }
-
- public double multiply(double b) {
- return console.changeCurrentValue(console.getCurrentValue() * b);
- }
-
- public double divide(double b) {
- if ( b != 0){
- return console.changeCurrentValue(console.getCurrentValue() / b);
- }else {console.println("Cannot Divide by 0, Please Try Another Number.");
- }
- return console.getCurrentValue();
- }
-
-
-
- public double square() {
- return console.changeCurrentValue( Math.pow(console.currentValue, 2));
- }
-
- public double squareRoot() {
- return console.changeCurrentValue( Math.sqrt(console.currentValue));
- }
-
- public double inverse() {
- return console.changeCurrentValue( (1/console.currentValue));
- }
-
- public double changeSign() {
- return console.changeCurrentValue((console.currentValue *= -1));
- }
-
- public double variableExponentiation(double b) {
- return console.changeCurrentValue(Math.pow(console.currentValue,b));
- }
-
-
- }
|