Last active
April 5, 2018 10:10
-
-
Save kanerogers/5192492 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericSimpleCalcFactoryFactory { | |
class SimpleCalcFactory { | |
class SimpleCalc { | |
double number = Integer.parseInt(args[0]); | |
if (number < 0){ | |
System.out.println(Math.pow(number, 2) + (number/2)); | |
return; | |
} | |
// Number is greater than zero | |
if ((number % 2 == 0)){ //even | |
System.out.println(Math.pow(number, 3) * (number - 1)); | |
} else { //odd | |
System.out.println(Math.pow(number, -1) + (3 * number)); | |
} | |
} | |
public SimpleCalc getSimpleCalc() { | |
return new SimpleCalc(); | |
} | |
} | |
public SimpleCalcFactory getSimpleCalcFactory() { | |
return new SimpleCalcFactory(); | |
} | |
} | |
public class SimpleCalcRunner { | |
public static void main(String[] args){ | |
double number = Integer.parseInt(args[0]); | |
SimpleCalc calc = GenericSimpleCalcFactoryFactory.getSimpleCalcFactory().getSimpleCalc(); | |
calc.calculate(number); | |
return; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am revisiting this with a big smile on my face, ahahaha