summaryrefslogtreecommitdiff
path: root/src/algorithmus/Palisaden.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/algorithmus/Palisaden.java')
-rwxr-xr-xsrc/algorithmus/Palisaden.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/algorithmus/Palisaden.java b/src/algorithmus/Palisaden.java
new file mode 100755
index 0000000..fa822d4
--- /dev/null
+++ b/src/algorithmus/Palisaden.java
@@ -0,0 +1,72 @@
+package algorithmus;
+
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JSpinner;
+
+public class Palisaden extends Algorithmus {
+
+ private String name;
+ private int n;
+
+ public Palisaden() {
+ name = "Palisaden";
+ n = 3;
+ }
+
+ @Override
+ public void options() {
+ JFrame frame = new JFrame();
+ frame.setLayout(null);
+ frame.setTitle("Palisaden");
+ frame.setSize(200, 150);
+ JLabel label = new JLabel("Reihen:");
+ label.setBounds(5, 30, 100, 20);
+ JSpinner spinner = new JSpinner();
+ spinner.setBounds(100, 30, 50, 20);
+ spinner.setValue(n);
+ JButton apply = new JButton("Speichern");
+ apply.setBounds(5, 55, 100, 20);
+ apply.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ n = (int) spinner.getValue();
+ }
+ });
+ frame.add(label);
+ frame.add(spinner);
+ frame.add(apply);
+ frame.setVisible(true);
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String encode(String input) {
+ String out = "";
+ int length = input.length();
+ String[] rows = new String[n];
+ for(int i = 0; i<n; i++)
+ rows[i] = "";
+ for(int i = 0; i<length; i++) {
+ rows[i%n] += input.charAt(i);
+ }
+ for(int i = 0; i<n; i++)
+ out += rows[i] + "\n";
+ return out;
+ }
+
+ @Override
+ public String decode(String input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}