first commit
This commit is contained in:
commit
be31103aff
|
@ -0,0 +1,7 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Intellij
|
||||
.idea/
|
||||
*.iml
|
||||
*.iws
|
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,135 @@
|
|||
<?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>
|
|
@ -0,0 +1,45 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?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>
|
|
@ -0,0 +1,10 @@
|
|||
package de.artem.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class page2 {
|
||||
private JPanel panel1;
|
||||
private JTextField textField2;
|
||||
private JPanel header;
|
||||
private JLabel searchedWordGer;
|
||||
}
|
|
@ -0,0 +1,347 @@
|
|||
package de.artem.main;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Materialien zu den zentralen NRW-Abiturpruefungen im Fach Informatik ab 2018
|
||||
* </p>
|
||||
* <p>
|
||||
* Generische Klasse List<ContentType>
|
||||
* </p>
|
||||
* <p>
|
||||
* Objekt der generischen Klasse List verwalten beliebig viele linear
|
||||
* angeordnete Objekte vom Typ ContentType. Auf hoechstens ein Listenobjekt,
|
||||
* aktuellesObjekt genannt, kann jeweils zugegriffen werden.<br />
|
||||
* Wenn eine Liste leer ist, vollstaendig durchlaufen wurde oder das aktuelle
|
||||
* Objekt am Ende der Liste geloescht wurde, gibt es kein aktuelles Objekt.<br />
|
||||
* Das erste oder das letzte Objekt einer Liste koennen durch einen Auftrag zum
|
||||
* aktuellen Objekt gemacht werden. Ausserdem kann das dem aktuellen Objekt
|
||||
* folgende Listenobjekt zum neuen aktuellen Objekt werden. <br />
|
||||
* 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 -------------- */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ----------- 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()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package de.artem.main;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// write your code here
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package de.artem.main;
|
||||
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class User {
|
||||
private VocabBox [] boxes;
|
||||
private int boxAmount;
|
||||
private int currentBox;
|
||||
/**
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
boxAmount=pBoxAmount;
|
||||
currentBox =0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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 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.
|
||||
*/
|
||||
public void removeVocab(String pVocab){
|
||||
for(int i =0;i<boxAmount;i++){
|
||||
while(boxes[i].getVocabsList().hasAccess()){
|
||||
boxes[i].removeVocabulary(pVocab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fragt nach einer Konsolen eingabe in form eines Strings
|
||||
* @return
|
||||
* gibt den in die Konsole eingegebenen String zurück.
|
||||
*/
|
||||
private String typeAwnser(){
|
||||
Scanner console = new Scanner(System.in);
|
||||
return console.nextLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public boolean testAwnser(String pAwnser,String testedLanguage){
|
||||
String lang;
|
||||
if(testedLanguage.equalsIgnoreCase("Englisch")){
|
||||
lang = boxes[currentBox].getGerman();
|
||||
} 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package de.artem.main;
|
||||
|
||||
public class VocabBox {
|
||||
|
||||
private List<Vocabs> vocabsList;
|
||||
|
||||
public VocabBox(){
|
||||
vocabsList=new List<Vocabs>();
|
||||
}
|
||||
|
||||
public String getGerman(){
|
||||
vocabsList.toFirst();
|
||||
return vocabsList.getContent().getGerman();
|
||||
}
|
||||
|
||||
public String getEnglish(){
|
||||
vocabsList.toFirst();
|
||||
return vocabsList.getContent().getEnglish();
|
||||
}
|
||||
|
||||
public List<Vocabs> getVocabsList(){
|
||||
return vocabsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Eine Vokabel der Box hinzu.
|
||||
* @param pGerman
|
||||
* Deutsche Vokabel.
|
||||
* @param pEnglish
|
||||
* Englische Vokabel.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public void removeVocabulary(String pVocab){
|
||||
vocabsList.toFirst();
|
||||
|
||||
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
|
||||
vocabsList.remove(); // Wenn die Vokabel gefunden Wurde wird sie entfernt
|
||||
return;// Methode wird beendet
|
||||
}
|
||||
vocabsList.next();// nächste Vokabel wird geprüft
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package de.artem.main;
|
||||
|
||||
public class Vocabs {
|
||||
private String german;
|
||||
private 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;
|
||||
}
|
||||
|
||||
public String getGerman(){
|
||||
return german;
|
||||
}
|
||||
|
||||
public String getEnglish(){
|
||||
return english;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue