Skip to content

Instantly share code, notes, and snippets.

@kanerogers
Last active April 5, 2018 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanerogers/5192492 to your computer and use it in GitHub Desktop.
Save kanerogers/5192492 to your computer and use it in GitHub Desktop.
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;
}
}
@harrisony
Copy link

I am revisiting this with a big smile on my face, ahahaha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment