Skip to content

Commit

Permalink
Third Commit.
Browse files Browse the repository at this point in the history
Main class created.
UML class diagram added.
input.txt and output.txt added for passing arguments
  • Loading branch information
gulbalasalamov committed Feb 27, 2021
1 parent 2653bd0 commit 39de112
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
Binary file added FactoryPatternDemoGIF.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FactoryPatternUMLClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions client/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package client;

import factory.AlgFactory;
import model.AlgBase;

import java.io.File;

public class Main {
public static void main(String[] args) throws Exception {
String mode = "enc";
String alg = "shift";
StringBuilder msg = new StringBuilder();
int key = 0;
File outputFile = null;
File inputFile = null;

for (int i = 0; i < args.length; i += 2) {
switch (args[i]) {
case "-mode":
mode = args[i + 1];
break;
case "-key":
key = Integer.parseInt(args[i + 1]);
break;
case "-data":
msg.append(args[i + 1]);
break;
case "-in":
if ("".equals(msg.toString())) {
inputFile = new File(args[i + 1]);
}
break;
case "-out":
outputFile = new File(args[i + 1]);
outputFile.createNewFile();
break;
case "-alg":
alg = args[i + 1];
break;
}
}

AlgBase algorithm = AlgFactory.createAlgorithm(alg, msg.toString(), mode, key);
if ("enc".equals(mode)) {
algorithm.encrypt(inputFile, outputFile);
} else {
algorithm.decrypt(inputFile, outputFile);
}
}
}
Empty file added input.txt
Empty file.
Empty file added output.txt
Empty file.

0 comments on commit 39de112

Please sign in to comment.