Skip to content

Latest commit

Β 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 
Β 
Β 

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