GUI changed and doVocabsGerToEng() partwise implemented
This commit is contained in:
parent
be31103aff
commit
6320c9daa9
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="out/production/VocabBox"/>
|
||||
</classpath>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>VocabTrainer</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1 @@
|
|||
/de/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,184 @@
|
|||
package de.artem.gui;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.CardLayout;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JCheckBox;
|
||||
import java.awt.Font;
|
||||
import javax.swing.SwingConstants;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class Frame1 {
|
||||
|
||||
private JFrame frame;
|
||||
private JTextField tfGermanVoc;
|
||||
private JTextField tfEnglischVoc;
|
||||
private JTextField tfEngVoc;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Frame1 window = new Frame1();
|
||||
window.frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application.
|
||||
*/
|
||||
public Frame1() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
private void initialize() {
|
||||
frame = new JFrame();
|
||||
frame.setBounds(100, 100, 450, 300);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.getContentPane().setLayout(new CardLayout(0, 0));
|
||||
|
||||
JPanel page1 = new JPanel();
|
||||
frame.getContentPane().add(page1, "name_116096290208200");
|
||||
page1.setLayout(null);
|
||||
|
||||
JButton btnWeiter = new JButton("Weiter zum Training");
|
||||
btnWeiter.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnWeiter.setBounds(131, 208, 168, 23);
|
||||
page1.add(btnWeiter);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("F\u00FCge Deine Vokabeln Hinzu!");
|
||||
lblNewLabel.setBounds(153, 11, 220, 14);
|
||||
page1.add(lblNewLabel);
|
||||
|
||||
tfGermanVoc = new JTextField();
|
||||
tfGermanVoc.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
tfGermanVoc.setBounds(131, 113, 109, 20);
|
||||
page1.add(tfGermanVoc);
|
||||
tfGermanVoc.setColumns(10);
|
||||
|
||||
tfEnglischVoc = new JTextField();
|
||||
tfEnglischVoc.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
tfEnglischVoc.setBounds(250, 113, 123, 20);
|
||||
page1.add(tfEnglischVoc);
|
||||
tfEnglischVoc.setColumns(10);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Deutsche Vokabel");
|
||||
lblNewLabel_1.setBounds(131, 99, 97, 14);
|
||||
page1.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Englische Vokabel");
|
||||
lblNewLabel_2.setBounds(250, 99, 86, 14);
|
||||
page1.add(lblNewLabel_2);
|
||||
|
||||
JButton btnHinzufuegen = new JButton("Hinzuf\u00FCgen");
|
||||
btnHinzufuegen.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnHinzufuegen.setBounds(10, 112, 89, 23);
|
||||
page1.add(btnHinzufuegen);
|
||||
|
||||
JCheckBox chckbxEngDe = new JCheckBox("Englisch zu Deutsch");
|
||||
chckbxEngDe.setBounds(10, 168, 148, 23);
|
||||
page1.add(chckbxEngDe);
|
||||
|
||||
JPanel page2 = new JPanel();
|
||||
frame.getContentPane().add(page2, "name_116105745826300");
|
||||
page2.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("Schreibe die Englische Vokabel hin!");
|
||||
lblNewLabel_3.setBounds(138, 5, 256, 14);
|
||||
page2.add(lblNewLabel_3);
|
||||
|
||||
tfEngVoc = new JTextField();
|
||||
tfEngVoc.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
tfEngVoc.setBounds(79, 138, 281, 20);
|
||||
page2.add(tfEngVoc);
|
||||
tfEngVoc.setColumns(10);
|
||||
|
||||
JLabel germanVoc = new JLabel("Deutsche Vokabel");
|
||||
germanVoc.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
germanVoc.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||
germanVoc.setBounds(79, 94, 281, 20);
|
||||
page2.add(germanVoc);
|
||||
|
||||
JButton btnPruefen = new JButton("Pr\u00FCfen");
|
||||
btnPruefen.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnPruefen.setBounds(176, 195, 89, 23);
|
||||
page2.add(btnPruefen);
|
||||
|
||||
JButton btnBox1 = new JButton("Box1");
|
||||
btnBox1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnBox1.setBounds(10, 5, 89, 23);
|
||||
page2.add(btnBox1);
|
||||
|
||||
JButton btnBox2 = new JButton("Box2");
|
||||
btnBox2.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnBox2.setBounds(10, 33, 89, 23);
|
||||
page2.add(btnBox2);
|
||||
|
||||
JButton btnBox3 = new JButton("Box3");
|
||||
btnBox3.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnBox3.setBounds(10, 60, 89, 23);
|
||||
page2.add(btnBox3);
|
||||
|
||||
JButton btnBox4 = new JButton("Box4");
|
||||
btnBox4.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
}
|
||||
});
|
||||
btnBox4.setBounds(10, 91, 89, 23);
|
||||
page2.add(btnBox4);
|
||||
|
||||
JLabel lblNewLabel_5 = new JLabel("Box Inhalt:");
|
||||
lblNewLabel_5.setBounds(10, 236, 65, 14);
|
||||
page2.add(lblNewLabel_5);
|
||||
|
||||
JLabel boxInhalt = new JLabel("Inhalt der Box");
|
||||
boxInhalt.setBounds(79, 236, 65, 14);
|
||||
page2.add(boxInhalt);
|
||||
|
||||
frame.add(page1);
|
||||
frame.add(page2);
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.artem.gui.VocabTrainerGui">
|
||||
<grid id="27dc6" binding="addVocabulary" layout-manager="GridLayoutManager" row-count="7" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="1" vgap="1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="1" y="4" width="574" height="456"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-2306"/>
|
||||
<enabled value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="52334">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<hspacer id="985db">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="215" height="11"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="ff8dc" class="javax.swing.JTextField" binding="addGerman">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="9" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="115" height="40"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<vspacer id="f8567">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="2" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="215" height="14"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<vspacer id="48205">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="8cf90" class="javax.swing.JButton" binding="hinzufügenButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="115" height="40"/>
|
||||
<preferred-size width="215" height="40"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<horizontalAlignment value="0"/>
|
||||
<text value="Hinzufügen"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6f027" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Deutsch"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="fc2c3" class="javax.swing.JTextField" binding="addEnglish">
|
||||
<constraints>
|
||||
<grid row="3" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="115" height="40"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="2cfde" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Englisch"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="a54cb">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="f41e7" class="javax.swing.JButton" binding="nextPage">
|
||||
<constraints>
|
||||
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Weiter zum Lernen!"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="ef980">
|
||||
<constraints>
|
||||
<grid row="4" column="2" row-span="2" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="f965e" class="javax.swing.JLabel" binding="addInfo">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="215" height="20"/>
|
||||
<maximum-size width="9000" height="50"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="asdasdasdasdasdasdasasdasdasdasdasddasdasdasd"/>
|
||||
<verticalAlignment value="0"/>
|
||||
</properties>
|
||||
<clientProperties>
|
||||
<html.disable class="java.lang.Boolean" value="true"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
<component id="59209" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="true"/>
|
||||
<foreground color="-16777216"/>
|
||||
<text value="Füge Vokabeln Hinzu!"/>
|
||||
<verticalAlignment value="0"/>
|
||||
</properties>
|
||||
<clientProperties>
|
||||
<html.disable class="java.lang.Boolean" value="false"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
|
@ -1,45 +0,0 @@
|
|||
package de.artem.gui;
|
||||
|
||||
import de.artem.main.User;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class VocabTrainerGui {
|
||||
private JPanel addVocabulary;
|
||||
private JButton hinzufügenButton;
|
||||
private JTextField addEnglish;
|
||||
private JTextField addGerman;
|
||||
private JButton nextPage;
|
||||
private JLabel addInfo;
|
||||
User user;
|
||||
|
||||
|
||||
public VocabTrainerGui() {
|
||||
user = new User(4);
|
||||
|
||||
hinzufügenButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(addGerman.getText()!=null || addEnglish.getText()!=null ) {
|
||||
user.addVocab(addGerman.getText(), addEnglish.getText());
|
||||
addInfo.setText(addGerman.getText() + ", "+ addEnglish.getText() + " Hinzugefügt");
|
||||
}
|
||||
}
|
||||
});
|
||||
nextPage.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame frame = new JFrame("VokabelTrainer");
|
||||
frame.setContentPane(new VocabTrainerGui().addVocabulary);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.artem.gui.page2">
|
||||
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="bc6de" binding="header" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-2306"/>
|
||||
<foreground color="-16777216"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9dd0" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<foreground color="-16777216"/>
|
||||
<text value="Schreibe das Englische Wort"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e3693" class="javax.swing.JTextField" binding="textField2" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="2" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-2306"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f6c1b" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="VocabelTrainer"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="11657" class="javax.swing.JLabel" binding="searchedWordGer">
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<foreground color="-16777216"/>
|
||||
<horizontalAlignment value="2"/>
|
||||
<text value="GerWort"/>
|
||||
<verticalAlignment value="3"/>
|
||||
<verticalTextPosition value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
|
@ -1,10 +0,0 @@
|
|||
package de.artem.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class page2 {
|
||||
private JPanel panel1;
|
||||
private JTextField textField2;
|
||||
private JPanel header;
|
||||
private JLabel searchedWordGer;
|
||||
}
|
|
@ -19,329 +19,322 @@ package de.artem.main;
|
|||
* Das aktuelle Objekt kann gelesen, veraendert oder geloescht werden. Ausserdem
|
||||
* kann vor dem aktuellen Objekt ein Listenobjekt eingefuegt werden.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Qualitaets- und UnterstuetzungsAgentur - Landesinstitut fuer Schule
|
||||
* @version Generisch_06 2015-10-25
|
||||
*/
|
||||
public class List<ContentType> {
|
||||
|
||||
/* --------- Anfang der privaten inneren Klasse -------------- */
|
||||
/* --------- Anfang der privaten inneren Klasse -------------- */
|
||||
|
||||
private class ListNode {
|
||||
// erstes Element der Liste
|
||||
ListNode first;
|
||||
|
||||
private ContentType contentObject;
|
||||
private ListNode next;
|
||||
/* ----------- Ende der privaten inneren Klasse -------------- */
|
||||
// letztes Element der Liste
|
||||
ListNode last;
|
||||
// aktuelles Element der Liste
|
||||
ListNode current;
|
||||
|
||||
/**
|
||||
* Ein neues Objekt wird erschaffen. Der Verweis ist leer.
|
||||
*
|
||||
* @param pContent das Inhaltsobjekt vom Typ ContentType
|
||||
* Eine leere Liste wird erzeugt.
|
||||
*/
|
||||
private ListNode(ContentType pContent) {
|
||||
contentObject = pContent;
|
||||
next = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Inhalt des Knotens wird zurueckgeliefert.
|
||||
*
|
||||
* @return das Inhaltsobjekt des Knotens
|
||||
*/
|
||||
public ContentType getContentObject() {
|
||||
return contentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Inhalt dieses Kontens wird gesetzt.
|
||||
*
|
||||
* @param pContent das Inhaltsobjekt vom Typ ContentType
|
||||
*/
|
||||
public void setContentObject(ContentType pContent) {
|
||||
contentObject = pContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Nachfolgeknoten wird zurueckgeliefert.
|
||||
*
|
||||
* @return das Objekt, auf das der aktuelle Verweis zeigt
|
||||
*/
|
||||
public ListNode getNextNode() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Verweis wird auf das Objekt, das als Parameter uebergeben
|
||||
* wird, gesetzt.
|
||||
*
|
||||
* @param pNext der Nachfolger des Knotens
|
||||
*/
|
||||
public void setNextNode(ListNode pNext) {
|
||||
this.next = pNext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ----------- Ende der privaten inneren Klasse -------------- */
|
||||
|
||||
// erstes Element der Liste
|
||||
ListNode first;
|
||||
|
||||
// letztes Element der Liste
|
||||
ListNode last;
|
||||
|
||||
// aktuelles Element der Liste
|
||||
ListNode current;
|
||||
|
||||
/**
|
||||
* Eine leere Liste wird erzeugt.
|
||||
*/
|
||||
public List() {
|
||||
first = null;
|
||||
last = null;
|
||||
current = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Anfrage liefert den Wert true, wenn die Liste keine Objekte enthaelt,
|
||||
* sonst liefert sie den Wert false.
|
||||
*
|
||||
* @return true, wenn die Liste leer ist, sonst false
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
// Die Liste ist leer, wenn es kein erstes Element gibt.
|
||||
return first == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Anfrage liefert den Wert true, wenn es ein aktuelles Objekt gibt,
|
||||
* sonst liefert sie den Wert false.
|
||||
*
|
||||
* @return true, falls Zugriff moeglich, sonst false
|
||||
*/
|
||||
public boolean hasAccess() {
|
||||
// Es gibt keinen Zugriff, wenn current auf kein Element verweist.
|
||||
return current != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls die Liste nicht leer ist, es ein aktuelles Objekt gibt und dieses
|
||||
* nicht das letzte Objekt der Liste ist, wird das dem aktuellen Objekt in
|
||||
* der Liste folgende Objekt zum aktuellen Objekt, andernfalls gibt es nach
|
||||
* Ausfuehrung des Auftrags kein aktuelles Objekt, d.h. hasAccess() liefert
|
||||
* den Wert false.
|
||||
*/
|
||||
public void next() {
|
||||
if (this.hasAccess()) {
|
||||
current = current.getNextNode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls die Liste nicht leer ist, wird das erste Objekt der Liste aktuelles
|
||||
* Objekt. Ist die Liste leer, geschieht nichts.
|
||||
*/
|
||||
public void toFirst() {
|
||||
if (!isEmpty()) {
|
||||
current = first;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls die Liste nicht leer ist, wird das letzte Objekt der Liste
|
||||
* aktuelles Objekt. Ist die Liste leer, geschieht nichts.
|
||||
*/
|
||||
public void toLast() {
|
||||
if (!isEmpty()) {
|
||||
current = last;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true), wird das
|
||||
* aktuelle Objekt zurueckgegeben, andernfalls (hasAccess() == false) gibt
|
||||
* die Anfrage den Wert null zurueck.
|
||||
*
|
||||
* @return das aktuelle Objekt (vom Typ ContentType) oder null, wenn es
|
||||
* kein aktuelles Objekt gibt
|
||||
*/
|
||||
public ContentType getContent() {
|
||||
if (this.hasAccess()) {
|
||||
return current.getContentObject();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true) und pContent
|
||||
* ungleich null ist, wird das aktuelle Objekt durch pContent ersetzt. Sonst
|
||||
* geschieht nichts.
|
||||
*
|
||||
* @param pContent
|
||||
* das zu schreibende Objekt vom Typ ContentType
|
||||
*/
|
||||
public void setContent(ContentType pContent) {
|
||||
// Nichts tun, wenn es keinen Inhalt oder kein aktuelles Element gibt.
|
||||
if (pContent != null && this.hasAccess()) {
|
||||
current.setContentObject(pContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true), wird ein neues
|
||||
* Objekt vor dem aktuellen Objekt in die Liste eingefuegt. Das aktuelle
|
||||
* Objekt bleibt unveraendert. <br />
|
||||
* Wenn die Liste leer ist, wird pContent in die Liste eingefuegt und es
|
||||
* gibt weiterhin kein aktuelles Objekt (hasAccess() == false). <br />
|
||||
* Falls es kein aktuelles Objekt gibt (hasAccess() == false) und die Liste
|
||||
* nicht leer ist oder pContent gleich null ist, geschieht nichts.
|
||||
*
|
||||
* @param pContent
|
||||
* das einzufuegende Objekt vom Typ ContentType
|
||||
*/
|
||||
public void insert(ContentType pContent) {
|
||||
if (pContent != null) { // Nichts tun, wenn es keinen Inhalt gibt.
|
||||
if (this.hasAccess()) { // Fall: Es gibt ein aktuelles Element.
|
||||
|
||||
// Neuen Knoten erstellen.
|
||||
ListNode newNode = new ListNode(pContent);
|
||||
|
||||
if (current != first) { // Fall: Nicht an erster Stelle einfuegen.
|
||||
ListNode previous = this.getPrevious(current);
|
||||
newNode.setNextNode(previous.getNextNode());
|
||||
previous.setNextNode(newNode);
|
||||
} else { // Fall: An erster Stelle einfuegen.
|
||||
newNode.setNextNode(first);
|
||||
first = newNode;
|
||||
}
|
||||
|
||||
} else { //Fall: Es gibt kein aktuelles Element.
|
||||
|
||||
if (this.isEmpty()) { // Fall: In leere Liste einfuegen.
|
||||
|
||||
// Neuen Knoten erstellen.
|
||||
ListNode newNode = new ListNode(pContent);
|
||||
|
||||
first = newNode;
|
||||
last = newNode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls pContent gleich null ist, geschieht nichts.<br />
|
||||
* Ansonsten wird ein neues Objekt pContent am Ende der Liste eingefuegt.
|
||||
* Das aktuelle Objekt bleibt unveraendert. <br />
|
||||
* Wenn die Liste leer ist, wird das Objekt pContent in die Liste eingefuegt
|
||||
* und es gibt weiterhin kein aktuelles Objekt (hasAccess() == false).
|
||||
*
|
||||
* @param pContent
|
||||
* das anzuhaengende Objekt vom Typ ContentType
|
||||
*/
|
||||
public void append(ContentType pContent) {
|
||||
if (pContent != null) { // Nichts tun, wenn es keine Inhalt gibt.
|
||||
|
||||
if (this.isEmpty()) { // Fall: An leere Liste anfuegen.
|
||||
this.insert(pContent);
|
||||
} else { // Fall: An nicht-leere Liste anfuegen.
|
||||
|
||||
// Neuen Knoten erstellen.
|
||||
ListNode newNode = new ListNode(pContent);
|
||||
|
||||
last.setNextNode(newNode);
|
||||
last = newNode; // Letzten Knoten aktualisieren.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es sich bei der Liste und pList um dasselbe Objekt handelt,
|
||||
* pList null oder eine leere Liste ist, geschieht nichts.<br />
|
||||
* Ansonsten wird die Liste pList an die aktuelle Liste angehaengt.
|
||||
* Anschliessend wird pList eine leere Liste. Das aktuelle Objekt bleibt
|
||||
* unveraendert. Insbesondere bleibt hasAccess identisch.
|
||||
*
|
||||
* @param pList
|
||||
* die am Ende anzuhaengende Liste vom Typ List<ContentType>
|
||||
*/
|
||||
public void concat(List<ContentType> pList) {
|
||||
if (pList != this && pList != null && !pList.isEmpty()) { // Nichts tun,
|
||||
// wenn pList und this identisch, pList leer oder nicht existent.
|
||||
|
||||
if (this.isEmpty()) { // Fall: An leere Liste anfuegen.
|
||||
this.first = pList.first;
|
||||
this.last = pList.last;
|
||||
} else { // Fall: An nicht-leere Liste anfuegen.
|
||||
this.last.setNextNode(pList.first);
|
||||
this.last = pList.last;
|
||||
}
|
||||
|
||||
// Liste pList loeschen.
|
||||
pList.first = null;
|
||||
pList.last = null;
|
||||
pList.current = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wenn die Liste leer ist oder es kein aktuelles Objekt gibt (hasAccess()
|
||||
* == false), geschieht nichts.<br />
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true), wird das
|
||||
* aktuelle Objekt geloescht und das Objekt hinter dem geloeschten Objekt
|
||||
* wird zum aktuellen Objekt. <br />
|
||||
* Wird das Objekt, das am Ende der Liste steht, geloescht, gibt es kein
|
||||
* aktuelles Objekt mehr.
|
||||
*/
|
||||
public void remove() {
|
||||
// Nichts tun, wenn es kein aktuelle Element gibt oder die Liste leer ist.
|
||||
if (this.hasAccess() && !this.isEmpty()) {
|
||||
|
||||
if (current == first) {
|
||||
first = first.getNextNode();
|
||||
} else {
|
||||
ListNode previous = this.getPrevious(current);
|
||||
if (current == last) {
|
||||
last = previous;
|
||||
}
|
||||
previous.setNextNode(current.getNextNode());
|
||||
}
|
||||
|
||||
ListNode temp = current.getNextNode();
|
||||
current.setContentObject(null);
|
||||
current.setNextNode(null);
|
||||
current = temp;
|
||||
|
||||
//Beim loeschen des letzten Elements last auf null setzen.
|
||||
if (this.isEmpty()) {
|
||||
public List() {
|
||||
first = null;
|
||||
last = null;
|
||||
}
|
||||
current = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert den Vorgaengerknoten des Knotens pNode. Ist die Liste leer, pNode
|
||||
* == null, pNode nicht in der Liste oder pNode der erste Knoten der Liste,
|
||||
* wird null zurueckgegeben.
|
||||
*
|
||||
* @param pNode
|
||||
* der Knoten, dessen Vorgaenger zurueckgegeben werden soll
|
||||
* @return der Vorgaenger des Knotens pNode oder null, falls die Liste leer ist,
|
||||
* pNode == null ist, pNode nicht in der Liste ist oder pNode der erste Knoten
|
||||
* der Liste ist
|
||||
*/
|
||||
private ListNode getPrevious(ListNode pNode) {
|
||||
if (pNode != null && pNode != first && !this.isEmpty()) {
|
||||
ListNode temp = first;
|
||||
while (temp != null && temp.getNextNode() != pNode) {
|
||||
temp = temp.getNextNode();
|
||||
}
|
||||
return temp;
|
||||
} else {
|
||||
return null;
|
||||
/**
|
||||
* Die Anfrage liefert den Wert true, wenn die Liste keine Objekte enthaelt,
|
||||
* sonst liefert sie den Wert false.
|
||||
*
|
||||
* @return true, wenn die Liste leer ist, sonst false
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
// Die Liste ist leer, wenn es kein erstes Element gibt.
|
||||
return first == null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Die Anfrage liefert den Wert true, wenn es ein aktuelles Objekt gibt,
|
||||
* sonst liefert sie den Wert false.
|
||||
*
|
||||
* @return true, falls Zugriff moeglich, sonst false
|
||||
*/
|
||||
public boolean hasAccess() {
|
||||
// Es gibt keinen Zugriff, wenn current auf kein Element verweist.
|
||||
return current != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls die Liste nicht leer ist, es ein aktuelles Objekt gibt und dieses
|
||||
* nicht das letzte Objekt der Liste ist, wird das dem aktuellen Objekt in
|
||||
* der Liste folgende Objekt zum aktuellen Objekt, andernfalls gibt es nach
|
||||
* Ausfuehrung des Auftrags kein aktuelles Objekt, d.h. hasAccess() liefert
|
||||
* den Wert false.
|
||||
*/
|
||||
public void next() {
|
||||
if (this.hasAccess()) {
|
||||
current = current.getNextNode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls die Liste nicht leer ist, wird das erste Objekt der Liste aktuelles
|
||||
* Objekt. Ist die Liste leer, geschieht nichts.
|
||||
*/
|
||||
public void toFirst() {
|
||||
if (!isEmpty()) {
|
||||
current = first;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls die Liste nicht leer ist, wird das letzte Objekt der Liste
|
||||
* aktuelles Objekt. Ist die Liste leer, geschieht nichts.
|
||||
*/
|
||||
public void toLast() {
|
||||
if (!isEmpty()) {
|
||||
current = last;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true), wird das
|
||||
* aktuelle Objekt zurueckgegeben, andernfalls (hasAccess() == false) gibt
|
||||
* die Anfrage den Wert null zurueck.
|
||||
*
|
||||
* @return das aktuelle Objekt (vom Typ ContentType) oder null, wenn es
|
||||
* kein aktuelles Objekt gibt
|
||||
*/
|
||||
public ContentType getContent() {
|
||||
if (this.hasAccess()) {
|
||||
return current.getContentObject();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true) und pContent
|
||||
* ungleich null ist, wird das aktuelle Objekt durch pContent ersetzt. Sonst
|
||||
* geschieht nichts.
|
||||
*
|
||||
* @param pContent das zu schreibende Objekt vom Typ ContentType
|
||||
*/
|
||||
public void setContent(ContentType pContent) {
|
||||
// Nichts tun, wenn es keinen Inhalt oder kein aktuelles Element gibt.
|
||||
if (pContent != null && this.hasAccess()) {
|
||||
current.setContentObject(pContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true), wird ein neues
|
||||
* Objekt vor dem aktuellen Objekt in die Liste eingefuegt. Das aktuelle
|
||||
* Objekt bleibt unveraendert. <br />
|
||||
* Wenn die Liste leer ist, wird pContent in die Liste eingefuegt und es
|
||||
* gibt weiterhin kein aktuelles Objekt (hasAccess() == false). <br />
|
||||
* Falls es kein aktuelles Objekt gibt (hasAccess() == false) und die Liste
|
||||
* nicht leer ist oder pContent gleich null ist, geschieht nichts.
|
||||
*
|
||||
* @param pContent das einzufuegende Objekt vom Typ ContentType
|
||||
*/
|
||||
public void insert(ContentType pContent) {
|
||||
if (pContent != null) { // Nichts tun, wenn es keinen Inhalt gibt.
|
||||
if (this.hasAccess()) { // Fall: Es gibt ein aktuelles Element.
|
||||
|
||||
// Neuen Knoten erstellen.
|
||||
ListNode newNode = new ListNode(pContent);
|
||||
|
||||
if (current != first) { // Fall: Nicht an erster Stelle einfuegen.
|
||||
ListNode previous = this.getPrevious(current);
|
||||
newNode.setNextNode(previous.getNextNode());
|
||||
previous.setNextNode(newNode);
|
||||
} else { // Fall: An erster Stelle einfuegen.
|
||||
newNode.setNextNode(first);
|
||||
first = newNode;
|
||||
}
|
||||
|
||||
} else { //Fall: Es gibt kein aktuelles Element.
|
||||
|
||||
if (this.isEmpty()) { // Fall: In leere Liste einfuegen.
|
||||
|
||||
// Neuen Knoten erstellen.
|
||||
ListNode newNode = new ListNode(pContent);
|
||||
|
||||
first = newNode;
|
||||
last = newNode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls pContent gleich null ist, geschieht nichts.<br />
|
||||
* Ansonsten wird ein neues Objekt pContent am Ende der Liste eingefuegt.
|
||||
* Das aktuelle Objekt bleibt unveraendert. <br />
|
||||
* Wenn die Liste leer ist, wird das Objekt pContent in die Liste eingefuegt
|
||||
* und es gibt weiterhin kein aktuelles Objekt (hasAccess() == false).
|
||||
*
|
||||
* @param pContent das anzuhaengende Objekt vom Typ ContentType
|
||||
*/
|
||||
public void append(ContentType pContent) {
|
||||
if (pContent != null) { // Nichts tun, wenn es keine Inhalt gibt.
|
||||
|
||||
if (this.isEmpty()) { // Fall: An leere Liste anfuegen.
|
||||
this.insert(pContent);
|
||||
} else { // Fall: An nicht-leere Liste anfuegen.
|
||||
|
||||
// Neuen Knoten erstellen.
|
||||
ListNode newNode = new ListNode(pContent);
|
||||
|
||||
last.setNextNode(newNode);
|
||||
last = newNode; // Letzten Knoten aktualisieren.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Falls es sich bei der Liste und pList um dasselbe Objekt handelt,
|
||||
* pList null oder eine leere Liste ist, geschieht nichts.<br />
|
||||
* Ansonsten wird die Liste pList an die aktuelle Liste angehaengt.
|
||||
* Anschliessend wird pList eine leere Liste. Das aktuelle Objekt bleibt
|
||||
* unveraendert. Insbesondere bleibt hasAccess identisch.
|
||||
*
|
||||
* @param pList die am Ende anzuhaengende Liste vom Typ List<ContentType>
|
||||
*/
|
||||
public void concat(List<ContentType> pList) {
|
||||
if (pList != this && pList != null && !pList.isEmpty()) { // Nichts tun,
|
||||
// wenn pList und this identisch, pList leer oder nicht existent.
|
||||
|
||||
if (this.isEmpty()) { // Fall: An leere Liste anfuegen.
|
||||
this.first = pList.first;
|
||||
this.last = pList.last;
|
||||
} else { // Fall: An nicht-leere Liste anfuegen.
|
||||
this.last.setNextNode(pList.first);
|
||||
this.last = pList.last;
|
||||
}
|
||||
|
||||
// Liste pList loeschen.
|
||||
pList.first = null;
|
||||
pList.last = null;
|
||||
pList.current = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wenn die Liste leer ist oder es kein aktuelles Objekt gibt (hasAccess()
|
||||
* == false), geschieht nichts.<br />
|
||||
* Falls es ein aktuelles Objekt gibt (hasAccess() == true), wird das
|
||||
* aktuelle Objekt geloescht und das Objekt hinter dem geloeschten Objekt
|
||||
* wird zum aktuellen Objekt. <br />
|
||||
* Wird das Objekt, das am Ende der Liste steht, geloescht, gibt es kein
|
||||
* aktuelles Objekt mehr.
|
||||
*/
|
||||
public void remove() {
|
||||
// Nichts tun, wenn es kein aktuelle Element gibt oder die Liste leer ist.
|
||||
if (this.hasAccess() && !this.isEmpty()) {
|
||||
|
||||
if (current == first) {
|
||||
first = first.getNextNode();
|
||||
} else {
|
||||
ListNode previous = this.getPrevious(current);
|
||||
if (current == last) {
|
||||
last = previous;
|
||||
}
|
||||
previous.setNextNode(current.getNextNode());
|
||||
}
|
||||
|
||||
ListNode temp = current.getNextNode();
|
||||
current.setContentObject(null);
|
||||
current.setNextNode(null);
|
||||
current = temp;
|
||||
|
||||
//Beim loeschen des letzten Elements last auf null setzen.
|
||||
if (this.isEmpty()) {
|
||||
last = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert den Vorgaengerknoten des Knotens pNode. Ist die Liste leer, pNode
|
||||
* == null, pNode nicht in der Liste oder pNode der erste Knoten der Liste,
|
||||
* wird null zurueckgegeben.
|
||||
*
|
||||
* @param pNode der Knoten, dessen Vorgaenger zurueckgegeben werden soll
|
||||
* @return der Vorgaenger des Knotens pNode oder null, falls die Liste leer ist,
|
||||
* pNode == null ist, pNode nicht in der Liste ist oder pNode der erste Knoten
|
||||
* der Liste ist
|
||||
*/
|
||||
private ListNode getPrevious(ListNode pNode) {
|
||||
if (pNode != null && pNode != first && !this.isEmpty()) {
|
||||
ListNode temp = first;
|
||||
while (temp != null && temp.getNextNode() != pNode) {
|
||||
temp = temp.getNextNode();
|
||||
}
|
||||
return temp;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class ListNode {
|
||||
|
||||
private ContentType contentObject;
|
||||
private ListNode next;
|
||||
|
||||
/**
|
||||
* Ein neues Objekt wird erschaffen. Der Verweis ist leer.
|
||||
*
|
||||
* @param pContent das Inhaltsobjekt vom Typ ContentType
|
||||
*/
|
||||
private ListNode(ContentType pContent) {
|
||||
contentObject = pContent;
|
||||
next = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Inhalt des Knotens wird zurueckgeliefert.
|
||||
*
|
||||
* @return das Inhaltsobjekt des Knotens
|
||||
*/
|
||||
public ContentType getContentObject() {
|
||||
return contentObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Inhalt dieses Kontens wird gesetzt.
|
||||
*
|
||||
* @param pContent das Inhaltsobjekt vom Typ ContentType
|
||||
*/
|
||||
public void setContentObject(ContentType pContent) {
|
||||
contentObject = pContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Nachfolgeknoten wird zurueckgeliefert.
|
||||
*
|
||||
* @return das Objekt, auf das der aktuelle Verweis zeigt
|
||||
*/
|
||||
public ListNode getNextNode() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Verweis wird auf das Objekt, das als Parameter uebergeben
|
||||
* wird, gesetzt.
|
||||
*
|
||||
* @param pNext der Nachfolger des Knotens
|
||||
*/
|
||||
public void setNextNode(ListNode pNext) {
|
||||
this.next = pNext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package de.artem.main;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// write your code here
|
||||
}
|
||||
}
|
|
@ -4,47 +4,49 @@ package de.artem.main;
|
|||
import java.util.Scanner;
|
||||
|
||||
public class User {
|
||||
private VocabBox [] boxes;
|
||||
private int boxAmount;
|
||||
private final VocabBox[] boxes;
|
||||
private final int boxAmount;
|
||||
private int currentBox;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pBoxAmount
|
||||
* Gibt an wie viele Boxen der Vokabeltrainer haben soll.
|
||||
* @param pBoxAmount Gibt an wie viele Boxen der Vokabeltrainer haben soll.
|
||||
*/
|
||||
public User(int pBoxAmount){
|
||||
boxes= new VocabBox[pBoxAmount];
|
||||
for(int i =0;i<boxes.length;i++){
|
||||
boxes[i]= new VocabBox();
|
||||
public User(int pBoxAmount) {
|
||||
boxes = new VocabBox[pBoxAmount];
|
||||
for (int i = 0; i < boxes.length; i++) {
|
||||
boxes[i] = new VocabBox();
|
||||
}
|
||||
boxAmount=pBoxAmount;
|
||||
currentBox =0;
|
||||
boxAmount = pBoxAmount;
|
||||
currentBox = 0;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pBox
|
||||
* Gibt die Nummer der Box von 1 bis boxSize an.
|
||||
* @param pBox Gibt die Nummer der Box von 1 bis boxSize an.
|
||||
*/
|
||||
public void chooseBox(int pBox){
|
||||
currentBox=pBox;
|
||||
}
|
||||
public void addVocab(String pGerman, String pEnglish,int pBox){
|
||||
boxes[pBox].addVocabulary(pGerman,pEnglish);
|
||||
public void chooseBox(int pBox) {
|
||||
currentBox = pBox;
|
||||
}
|
||||
|
||||
public void addVocab(String pGerman, String pEnglish){
|
||||
boxes[0].addVocabulary(pGerman,pEnglish);
|
||||
public void addVocab(String pGerman, String pEnglish, int pBox) {
|
||||
boxes[pBox].addVocabulary(pGerman, pEnglish);
|
||||
}
|
||||
|
||||
public void addVocab(String pGerman, String pEnglish) {
|
||||
boxes[0].addVocabulary(pGerman, pEnglish);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht die Vokabel aus dem Spiel und entfernt sie.
|
||||
* @param pVocab
|
||||
* Kann beides, deutsche und Englische Vokabel sein.
|
||||
*
|
||||
* @param pVocab Kann beides, deutsche und Englische Vokabel sein.
|
||||
*/
|
||||
public void removeVocab(String pVocab){
|
||||
for(int i =0;i<boxAmount;i++){
|
||||
while(boxes[i].getVocabsList().hasAccess()){
|
||||
public void removeVocab(String pVocab) {
|
||||
for (int i = 0; i < boxAmount; i++) {
|
||||
while (boxes[i].getVocabsList().hasAccess()) {
|
||||
boxes[i].removeVocabulary(pVocab);
|
||||
}
|
||||
}
|
||||
|
@ -52,37 +54,53 @@ public class User {
|
|||
|
||||
/**
|
||||
* Fragt nach einer Konsolen eingabe in form eines Strings
|
||||
* @return
|
||||
* gibt den in die Konsole eingegebenen String zurück.
|
||||
*
|
||||
* @return gibt den in die Konsole eingegebenen String zurück.
|
||||
*/
|
||||
private String typeAwnser(){
|
||||
private String typeAwnser() {
|
||||
Scanner console = new Scanner(System.in);
|
||||
return console.nextLine();
|
||||
}
|
||||
|
||||
public void doVocabsGerToEng(){
|
||||
System.out.println("Übersetze das Wort:"+boxes[currentBox].getGerman());
|
||||
System.out.println("Tippe die Übersetzung!");
|
||||
String awnser = typeAwnser();
|
||||
if(testAwnser(awnser,"English")){
|
||||
if(currentBox<boxes.length){
|
||||
boxes[currentBox+1].getVocabsList().append(boxes[currentBox].getVocabsList().getContent());
|
||||
}
|
||||
boxes[currentBox].getVocabsList().remove();
|
||||
System.out.println("Die Awntwort ist Richtig!");
|
||||
System.out.println("Willst du deine Box ändern?: j oder n?");
|
||||
String jn=typeAwnser();
|
||||
if(jn.equalsIgnoreCase(j)){
|
||||
System.out.println("Tippe die Box ein.");
|
||||
jn = typeAwnser();
|
||||
chooseBox(Integer.parseInt(jn));
|
||||
//TODO: Zuende machen und Safety einbauen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob die Antwort in der angegebenen Sprache korrekt ist.
|
||||
* @return
|
||||
* gibt zurück ob die Antwort korrekt ist.
|
||||
* Falls die Getestete Sprache nicht unterstützt wird, wird auch false ausgegeben.
|
||||
* @param pAwnser
|
||||
* Ist die Antwort, die geprüft wird.
|
||||
* @param testedLanguage
|
||||
* die Sprache in der die Antwort geschrieben wurde.
|
||||
*
|
||||
* @param pAwnser Ist die Antwort, die geprüft wird.
|
||||
* @param testedLanguage die Sprache in der die Antwort geschrieben wurde.
|
||||
* @return gibt zurück ob die Antwort korrekt ist.
|
||||
* Falls die Getestete Sprache nicht unterstützt wird, wird auch false ausgegeben.
|
||||
*/
|
||||
public boolean testAwnser(String pAwnser,String testedLanguage){
|
||||
public boolean testAwnser(String pAwnser, String testedLanguage) {
|
||||
String lang;
|
||||
if(testedLanguage.equalsIgnoreCase("Englisch")){
|
||||
if (testedLanguage.equalsIgnoreCase("Englisch")) {
|
||||
lang = boxes[currentBox].getGerman();
|
||||
} else if(testedLanguage.equalsIgnoreCase("Deutsch")){
|
||||
} else if (testedLanguage.equalsIgnoreCase("Deutsch")) {
|
||||
lang = boxes[currentBox].getEnglish();
|
||||
} else {
|
||||
System.out.println("Error:Nicht unterstützte Sprache ausgewählt, testAwnser()");
|
||||
return false;
|
||||
}
|
||||
if(pAwnser.equals(lang)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return pAwnser.equals(lang);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,49 +2,48 @@ package de.artem.main;
|
|||
|
||||
public class VocabBox {
|
||||
|
||||
private List<Vocabs> vocabsList;
|
||||
private final List<Vocabs> vocabsList;
|
||||
|
||||
public VocabBox(){
|
||||
vocabsList=new List<Vocabs>();
|
||||
public VocabBox() {
|
||||
vocabsList = new List<Vocabs>();
|
||||
}
|
||||
|
||||
public String getGerman(){
|
||||
public String getGerman() {
|
||||
vocabsList.toFirst();
|
||||
return vocabsList.getContent().getGerman();
|
||||
}
|
||||
|
||||
public String getEnglish(){
|
||||
public String getEnglish() {
|
||||
vocabsList.toFirst();
|
||||
return vocabsList.getContent().getEnglish();
|
||||
}
|
||||
|
||||
public List<Vocabs> getVocabsList(){
|
||||
public List<Vocabs> getVocabsList() {
|
||||
return vocabsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Eine Vokabel der Box hinzu.
|
||||
* @param pGerman
|
||||
* Deutsche Vokabel.
|
||||
* @param pEnglish
|
||||
* Englische Vokabel.
|
||||
*
|
||||
* @param pGerman Deutsche Vokabel.
|
||||
* @param pEnglish Englische Vokabel.
|
||||
*/
|
||||
public void addVocabulary(String pGerman, String pEnglish){
|
||||
vocabsList.append(new Vocabs(pGerman,pEnglish));
|
||||
public void addVocabulary(String pGerman, String pEnglish) {
|
||||
vocabsList.append(new Vocabs(pGerman, pEnglish));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernt Vokabel. Deutsche oder englische Vokabel kann eingegeben werden.
|
||||
* @param pVocab
|
||||
* Zu Entfernende Vokabel
|
||||
*
|
||||
* @param pVocab Zu Entfernende Vokabel
|
||||
*/
|
||||
public void removeVocabulary(String pVocab){
|
||||
public void removeVocabulary(String pVocab) {
|
||||
vocabsList.toFirst();
|
||||
|
||||
while(vocabsList.hasAccess()){
|
||||
while (vocabsList.hasAccess()) {
|
||||
String tg = vocabsList.getContent().getGerman();//gibt deutsches Wort
|
||||
String te = vocabsList.getContent().getEnglish();//gibt englisches Wort
|
||||
if(pVocab.equals(te)||pVocab.equals(tg)){ // vergleicht zu entfernendes Wort mit jetzigen Vokabeln
|
||||
if (pVocab.equals(te) || pVocab.equals(tg)) { // vergleicht zu entfernendes Wort mit jetzigen Vokabeln
|
||||
vocabsList.remove(); // Wenn die Vokabel gefunden Wurde wird sie entfernt
|
||||
return;// Methode wird beendet
|
||||
}
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
package de.artem.main;
|
||||
|
||||
public class Vocabs {
|
||||
private String german;
|
||||
private String english;
|
||||
private final String german;
|
||||
private final String english;
|
||||
|
||||
/**
|
||||
* Erstellt eine neue Instanz von Vocabs
|
||||
* @param pGerman
|
||||
* Die Deutsche Vokabel.
|
||||
* @param pEnglish
|
||||
* Die Englische Vokabel.
|
||||
*/
|
||||
public Vocabs(String pGerman,String pEnglish){
|
||||
german=pGerman;
|
||||
english=pEnglish;
|
||||
*
|
||||
* @param pGerman Die Deutsche Vokabel.
|
||||
* @param pEnglish Die Englische Vokabel.
|
||||
*/
|
||||
public Vocabs(String pGerman, String pEnglish) {
|
||||
german = pGerman;
|
||||
english = pEnglish;
|
||||
}
|
||||
|
||||
public String getGerman(){
|
||||
public String getGerman() {
|
||||
return german;
|
||||
}
|
||||
|
||||
public String getEnglish(){
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue