-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factory class created to encapsulate object creation.
- Loading branch information
1 parent
7e1b19f
commit 2653bd0
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |