Skip to content

Latest commit

 

History

History
48 lines (41 loc) · 3.69 KB

File metadata and controls

48 lines (41 loc) · 3.69 KB

Design Pattern - Strategy

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.

Image of Strategy Design Pattern

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.

Folder structure

📁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