Initial Commit
This commit is contained in:
8
Source Code/Assignment12/.idea/.gitignore
generated
vendored
Normal file
8
Source Code/Assignment12/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\Assignment12\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
7
Source Code/Assignment12/.idea/codeStyles/Project.xml
generated
Normal file
7
Source Code/Assignment12/.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
Source Code/Assignment12/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
Source Code/Assignment12/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
6
Source Code/Assignment12/.idea/discord.xml
generated
Normal file
6
Source Code/Assignment12/.idea/discord.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT" />
|
||||
</component>
|
||||
</project>
|
6
Source Code/Assignment12/.idea/misc.xml
generated
Normal file
6
Source Code/Assignment12/.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Source Code/Assignment12/.idea/modules.xml
generated
Normal file
8
Source Code/Assignment12/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Assignment12.iml" filepath="$PROJECT_DIR$/Assignment12.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
Source Code/Assignment12/Assignment12.iml
Normal file
12
Source Code/Assignment12/Assignment12.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resource" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
13
Source Code/Assignment12/resource/cypherText.in
Normal file
13
Source Code/Assignment12/resource/cypherText.in
Normal file
@ -0,0 +1,13 @@
|
||||
5
|
||||
rrrcfieeeindtsndedogxceht
|
||||
3
|
||||
kcnanaehrduowahtrelilngaaxyttnipsivofct
|
||||
7
|
||||
mehnteeoumtaotpelunosisrcinmnozbozktageshsoeorlrpeowtnuo
|
||||
4
|
||||
xdutenkyeevnotomhooxxnyioweuoerymessngot
|
||||
6
|
||||
xnodithbonttchonyecneieejplmaompilro
|
||||
2
|
||||
aoerniewlltnroiryounfmawibeargadct
|
||||
0
|
73
Source Code/Assignment12/src/Decoder.java
Normal file
73
Source Code/Assignment12/src/Decoder.java
Normal file
@ -0,0 +1,73 @@
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Decodes encrypted text in a specific format
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class Decoder {
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
|
||||
Scanner scanFile = new Scanner(new File(args[0]));
|
||||
int cycleCount = 0;
|
||||
|
||||
scanFile.useDelimiter("\\A");
|
||||
String in = scanFile.next();
|
||||
|
||||
String[] codes = in.split("\\r?\\n");
|
||||
|
||||
for (String i: codes) {
|
||||
|
||||
if (i.length() > 1) {
|
||||
int columns = Integer.parseInt(codes[cycleCount * 2]);
|
||||
int rows = codes[cycleCount * 2 + 1].length() / columns;
|
||||
|
||||
char[][] decode = new char[rows][columns];
|
||||
|
||||
char[] chars = i.toCharArray();
|
||||
|
||||
int charCounter = 0;
|
||||
for (int k = 0; k < columns; k++) {
|
||||
|
||||
if (k % 2 != 0) {
|
||||
for (int j = 0; j < rows; j++) {
|
||||
decode[j][k] = chars[charCounter];
|
||||
charCounter++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int j = rows - 1; j > -1; j--) {
|
||||
decode[j][k] = chars[charCounter];
|
||||
charCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
charCounter = 0;
|
||||
char[] decodedChar = new char[i.length()];
|
||||
for (int j = 0; j < rows; j++) {
|
||||
|
||||
if (j % 2 == 0) {
|
||||
for (int k = 0; k < columns; k++) {
|
||||
decodedChar[charCounter] = decode[j][k];
|
||||
charCounter++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int k = columns - 1; k > -1; k--) {
|
||||
decodedChar[charCounter] = decode[j][k];
|
||||
charCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
cycleCount++;
|
||||
String output = String.valueOf(decodedChar);
|
||||
System.out.println(output);
|
||||
}
|
||||
else if (i.equals("0")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user