Skip to content

Commit

Permalink
Second Commit.
Browse files Browse the repository at this point in the history
Factory class created to encapsulate object creation.
  • Loading branch information
gulbalasalamov committed Feb 27, 2021
1 parent 7e1b19f commit 2653bd0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions factory/AlgFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package factory;

import model.AlgBase;
import product.AlgShift;
import product.AlgUnicode;


public class AlgFactory {
public static AlgBase createAlgorithm(String algorithmType, String data, String mode, int key) throws Exception {
switch (algorithmType) {
case "unicode":
return new AlgUnicode(data, mode, key);
case "shift":
return new AlgShift(data, mode, key);
default:
throw new Exception("Unspecified algorithm: " + algorithmType);
}
}
}

0 comments on commit 2653bd0

Please sign in to comment.