123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
-
- /**
- * Write a description of class CoreFeatures here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class CoreFeatures extends MainApplication {
- // instance variables - replace the example below with your own
- private double x;
- private double addedNumbers;
- //addition
- private double subtractedNumbers;
- //subtraction
- private double multipliedNumbers;
- //multiplication
- private double dividedNumbers;
- //divide
- private double squaredNumber;
- //square
- private double squareRoot;
- //square root
- private boolean calcRunning;
- //calculator status
- private double switchedNumber;
- //changing the sign of a number
- private double inversedNumber;
- //inversing a number
- private boolean clearCalculator;
- //clear button
- //private double memory;
- //number to be stored
- //public double m;
- //memory button
-
- /**
- * Constructor for objects of class CoreFeatures
- */
- public CoreFeatures(){
- // initialise instance variables
- x = 0;
- }
-
- public double addNumbers(double adding1, double adding2){
- addedNumbers = adding1 + adding2;
- return addedNumbers;}
-
- public double subtractNumbers(double subtracting1, double subtracting2){
- subtractedNumbers = subtracting1 - subtracting2;
- return subtractedNumbers;}
-
- public double multiplyNumbers(double multiplying1, double multiplying2){
- multipliedNumbers = multiplying1 * multiplying2;
- return multipliedNumbers;}
-
- public double divideNumbers(double dividing1, double dividing2){
- if (dividing2 == 0){
- System.out.println("**ERROR** CANNOT DIVIDE BY ZERO.");
- Console.result = 0;} else {
- dividedNumbers = dividing1 / dividing2;
- return dividedNumbers;}
-
- /*double userCorrectedInput = Console.getDoubleInput("**Err** CANNOT DIVIDE BY ZERO. Please clear the calculator.");
- return userCorrectedInput;*/
-
- /*dividedNumbers = dividing1 / dividing2;
- return dividedNumbers;*/
- return dividedNumbers;}
-
- public double squareNumber(double squaring){
- squaredNumber = squaring * squaring;
- return squaredNumber;}
-
- public double squareRoot(double squareRooting){
- squareRoot = squareRoot(squareRooting);
- return squareRoot;}
-
- public double switchSign(double switchingSign){
- switchedNumber = switchingSign * -1;
- return switchedNumber;
- }
-
- public double inverseNumber(double inversing){
- inversedNumber = 1/inversing;
- return inversedNumber;
- }
-
- public boolean clearCalculator(){
- clearCalculator = true;
- Console.result = 0;
- return clearCalculator;
- }
-
- public boolean calcRunning(){
- calcRunning = false;
- return calcRunning;
- }
-
- /*public double memoryStore(){
- memory = Console.result;
- if (memory == Console.result){
- m = memory;
- }
- return memory;
- }
- */
- }
|