Strategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. This pattern suggests that you take a class that does something specific in a lot of different ways and extract all of these algorithms into separate classes called strategies.
This repository contains two assignments done in Strategy pattern:
- Numbers
- Operations
Numbers π’
The task was to create classes, which will encapsulate different ways of displaying an int number in output:
- decimal,
- binary,
- hexadecimal.
Operations βββοΈβ
The task was to create classes, which will encapsulate different math operations with two int numbers:
- addition,
- substracton,
- multiplication,
- division.
πsrc
βββ πmain
βββ πjava
βββ πNumbers
β βββ πBinaryFormatter.java
β βββ πDecimalFormatter.java
β βββ πFormatter.java - interface
β βββ πHexadecimalFormatter.java
β βββ πIntegerNumber.java
β βββ πOctalFormatter.java
βββ πOperations
β βββ πAdd.java
β βββ πDivide.java
β βββ πMultiply.java
β βββ πNumberOperate.java
β βββ πOperator.java - interface
β βββ πSubstract.java
β
βββ πStrategyMain
βββ πMain.java- main class