Last active
January 13, 2020 10:57
-
-
Save ereshzealous/9f48489b2c5c054e9c092156e3df4da2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package com.minikube.sample.rest.controller; | |
| /** | |
| * Created By Gorantla, Eresh on 13/Jan/2020 | |
| **/ | |
| interface ArithmeticOperation { | |
| Double calculate(Double value1, Double value2); | |
| } | |
| interface LogicalOperation { | |
| Boolean calculate(Integer value); | |
| } | |
| class AdditionOperation implements ArithmeticOperation { | |
| @Override | |
| public Double calculate(Double value1, Double value2) { | |
| return value1 + value2; | |
| } | |
| } | |
| class SubtractionOperation implements ArithmeticOperation { | |
| @Override | |
| public Double calculate(Double value1, Double value2) { | |
| return value1 - value2; | |
| } | |
| } | |
| public class Main { | |
| public static void main(String[] args) { | |
| /** | |
| * Operation :: 1 --> Add, 2 --> Sub, 3 --> Multiply, 4 --> Division, 5 --> Mod | |
| */ | |
| Integer operation = 1; | |
| Double value1 = 0.0; | |
| Double value2 = 0.0; | |
| switch (operation) { | |
| case 1: | |
| AdditionOperation additionOperation = new AdditionOperation(); | |
| additionOperation.calculate(value1, value2); | |
| break; | |
| default: | |
| System.out.println("Operation not permitted.."); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment