MainApplication.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Created by leon on 2/9/18.
  3. */
  4. public class MainApplication {
  5. private void commandCenter(){
  6. //All the different feature objects
  7. CoreFeatures switchCoreFeatures = new CoreFeatures();
  8. //User instructions
  9. String userInput = Console.getStringInput("Choose a symbol for the corresponding function : " + "\n"
  10. + " |'+' = addition|" + "\n"+
  11. "|'-' = subtraction|");
  12. switch(userInput){
  13. case "+":
  14. double userInput2 = Console.getDoubleInput("Enter number to be added. ");
  15. Console.result = switchCoreFeatures.addNumbers(Console.result, userInput2);
  16. System.out.println(Console.result);
  17. break;
  18. case "-":
  19. double userInput3 = Console.getDoubleInput("Enter number to be subtracted. ");
  20. Console.result = switchCoreFeatures.subtractNumbers(Console.result, userInput3);
  21. System.out.println(Console.result);
  22. break;
  23. case "*":
  24. double userInput4 = Console.getDoubleInput("Enter number to be multiplied. ");
  25. Console.result = switchCoreFeatures.multiplyNumbers(Console.result, userInput4);
  26. System.out.println(Console.result);
  27. break;
  28. case "off":
  29. Console.calcRunning = false;
  30. break;
  31. }
  32. }
  33. public static void main(String[] args) {
  34. Console.println("Welcome to my calculator!");
  35. MainApplication mainApplication = new MainApplication();
  36. //String s = Console.getStringInput("Enter a string");
  37. //Integer i = Console.getIntegerInput("Enter an integer");
  38. //Double d = Console.getDoubleInput("Enter a double.");
  39. while (Console.calcRunning){
  40. //some sort of commads that take user input for a number
  41. mainApplication.commandCenter();
  42. }
  43. }
  44. }