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