Added method for checking answers

This commit is contained in:
maj83 2020-04-20 18:20:03 +01:00
parent b0866ff3c2
commit d530f6c79a
14 changed files with 820 additions and 0 deletions

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

View file

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="file://$PROJECT_DIR$/../javafx-sdk-14/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/../javafx-sdk-14/lib" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/../javafx-sdk-14/lib" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/../javafx-sdk-14/lib" recursive="false" type="SOURCES" />
</library>
</component>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Match the meaning.iml" filepath="$PROJECT_DIR$/Match the meaning.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,413 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="fbb2a4a0-47c2-4eac-8067-df2e585c83b3" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="23" selection-start-line="23" selection-end-line="23" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/MyController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416">
<caret line="114" selection-start-line="114" selection-end-line="114" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/DictionaryEntry.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="27" selection-start-line="27" selection-end-line="27" />
<folding>
<element signature="e#684#685#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/MatchTheMeaning.fxml">
<provider editor-type-id="JavaFX-Scene-Builder" />
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="275">
<caret line="55" column="86" lean-forward="true" selection-start-line="55" selection-start-column="86" selection-end-line="55" selection-end-column="86" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/DictionaryEntry.java" />
<option value="$PROJECT_DIR$/src/Main.java" />
<option value="$PROJECT_DIR$/src/MyController.java" />
<option value="$PROJECT_DIR$/src/MatchTheMeaning.fxml" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-9" />
<option name="y" value="-9" />
<option name="width" value="1938" />
<option name="height" value="1058" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes />
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1587042602227" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../javafx-sdk-14/lib" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="project.structure.last.edited" value="Libraries" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" />
<module name="Match the meaning" />
<option name="VM_PARAMETERS" value="--module-path C:\Users\Marcin\Desktop\javafx-sdk-14\lib --add-modules javafx.controls,javafx.fxml" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="fbb2a4a0-47c2-4eac-8067-df2e585c83b3" name="Default Changelist" comment="" />
<created>1586778885037</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1586778885037</updated>
<workItem from="1586778888266" duration="4356000" />
<workItem from="1586790476649" duration="5671000" />
<workItem from="1586796522495" duration="9386000" />
<workItem from="1587035664037" duration="6621000" />
<workItem from="1587208556418" duration="3298000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="29332000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<layout>
<window_info content_ui="combo" id="Project" order="0" weight="0.08848614" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.21776815" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.3163597" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Database Changes" order="9" />
<window_info anchor="bottom" id="Terminal" order="10" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
<window_info anchor="bottom" id="Messages" order="12" weight="0.32936078" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Database" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Maven" order="6" />
<window_info anchor="right" id="Capture Analysis" order="7" />
<window_info anchor="right" id="Palette&#9;" order="8" />
</layout>
<layout-to-restore>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.08848614" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.21776815" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Database Changes" order="9" />
<window_info anchor="bottom" id="Terminal" order="10" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
<window_info anchor="bottom" id="Messages" order="12" weight="0.32936078" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Database" order="4" />
<window_info anchor="right" id="Theme Preview" order="5" />
<window_info anchor="right" id="Maven" order="6" />
<window_info anchor="right" id="Capture Analysis" order="7" />
<window_info anchor="right" id="Palette&#9;" order="8" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/MyController.java</url>
<line>108</line>
<properties />
<option name="timeStamp" value="11" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/out/production/Match the meaning/DictionaryEntry.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="23" selection-start-line="23" selection-end-line="23" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.controls.jar!/javafx/scene/control/ComboBoxBase.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="213">
<caret line="135" selection-start-line="135" selection-end-line="135" />
<folding>
<element signature="e#4575#4576#0" expanded="true" />
<element signature="e#4608#4609#0" expanded="true" />
<element signature="e#4778#4779#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.base.jar!/javafx/beans/property/DoublePropertyBase.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="70" selection-start-line="70" selection-end-line="70" />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.graphics.jar!/javafx/stage/Window.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="163">
<caret line="435" selection-start-line="435" selection-end-line="435" />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.fxml.jar!/javafx/fxml/FXMLLoader.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="197">
<caret line="2424" selection-start-line="2424" selection-end-line="2424" />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.controls.jar!/javafx/scene/control/Labeled.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="202">
<caret line="91" selection-start-line="91" selection-end-line="91" />
<folding>
<element signature="e#3123#3124#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/MatchTheMeaning.fxml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="275">
<caret line="55" column="86" lean-forward="true" selection-start-line="55" selection-start-column="86" selection-end-line="55" selection-end-column="86" />
</state>
</provider>
<provider editor-type-id="JavaFX-Scene-Builder" />
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.base.jar!/javafx/beans/binding/StringExpression.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="16" selection-start-line="16" selection-end-line="16" />
<folding>
<element signature="e#460#461#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../javafx-sdk-14/lib/javafx.base.jar!/javafx/beans/property/StringPropertyBase.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="219">
<caret line="63" selection-start-line="63" selection-end-line="63" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/DictionaryEntry.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="27" selection-start-line="27" selection-end-line="27" />
<folding>
<element signature="e#684#685#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/MyController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416">
<caret line="114" selection-start-line="114" selection-end-line="114" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>No facets are configured</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>11</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>Match the meaning</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<last-edited>lib</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

View 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$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.Pane?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="MyController">
<children>
<Button fx:id="ConfirmButton" layoutX="271.0" layoutY="321.0" mnemonicParsing="false" text="Confirm" onAction="#checkAnswers" />
<Label layoutX="248.0" layoutY="356.0" text="Match the meaning" />
<ComboBox fx:id="word1" layoutX="448.0" layoutY="118.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="word2" layoutX="448.0" layoutY="153.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="word3" layoutX="448.0" layoutY="188.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="word4" layoutX="448.0" layoutY="223.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<Label fx:id="WelshWord1" layoutX="343.0" layoutY="122.0" text="Welsh word#3" />
<Label fx:id="WelshWord2" layoutX="343.0" layoutY="157.0" text="Welsh word#2" />
<Label fx:id="WelshWord3" layoutX="343.0" layoutY="192.0" text="Welsh word#1" />
<Label fx:id="WelshWord4" layoutX="343.0" layoutY="227.0" text="Welsh word#4" />
<Label fx:id="EngWord1" layoutX="115.0" layoutY="122.0" text="English Word #1" />
<Label fx:id="EngWord2" layoutX="115.0" layoutY="157.0" text="English Word #2" />
<Label fx:id="EngWord3" layoutX="115.0" layoutY="192.0" text="English Word #3" />
<Label fx:id="EngWord4" layoutX="115.0" layoutY="227.0" text="English Word #4" />
<Label layoutX="105.0" layoutY="122.0" text="1." />
<Label layoutX="105.0" layoutY="157.0" text="2." />
<Label layoutX="105.0" layoutY="192.0" text="3." />
<Label layoutX="105.0" layoutY="227.0" text="4." />
<Label layoutX="367.0" layoutY="23.0" text="Correct answers:" />
<Label layoutX="368.0" layoutY="53.0" text="Wrong answers:" />
<Label fx:id="CorrectAnswer" layoutX="463.0" layoutY="23.0" text="0" />
<Label fx:id="WrongAnswer" layoutX="463.0" layoutY="53.0" text="0" />
</children>
</Pane>

View file

@ -0,0 +1,64 @@
public class DictionaryEntry {
private String english;
private String welsh;
private String wordType;
private boolean practiceWord;
public DictionaryEntry(){
practiceWord = false;
}
public DictionaryEntry(String english, String welsh, String wordType ){
this.english = english;
this.welsh = welsh;
this.wordType = wordType;
}
public String getEnglish() {
return english;
}
public void setEnglish(String english) {
this.english = english;
}
public String getWelsh() {
return welsh;
}
public void setWelsh(String welsh) {
this.welsh = welsh;
}
public String getWordType() {
return wordType;
}
public void setWordType(String wordType) {
this.wordType = wordType;
}
public boolean isPracticeWord() {
return practiceWord;
}
public void setPracticeWord(boolean practiceWord) {
this.practiceWord = practiceWord;
}
@Override
public String toString() {
return "english='" + english + "'\t" +
"welsh='" + welsh + "'\t" +
"wordType='" + wordType + "'" +
"practiceWord = " + practiceWord;
}
}

View file

@ -0,0 +1,23 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Main extends Application{
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception{
Pane mainPane = FXMLLoader.load(Main.class.getResource("MatchTheMeaning.fxml"));
primaryStage.setScene(new Scene(mainPane));
primaryStage.show();
}
}

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.Pane?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="MyController">
<children>
<Button fx:id="ConfirmButton" layoutX="271.0" layoutY="321.0" mnemonicParsing="false" text="Confirm" onAction="#checkAnswers" />
<Label layoutX="248.0" layoutY="356.0" text="Match the meaning" />
<ComboBox fx:id="word1" layoutX="448.0" layoutY="118.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="word2" layoutX="448.0" layoutY="153.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="word3" layoutX="448.0" layoutY="188.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="word4" layoutX="448.0" layoutY="223.0" prefHeight="25.0" prefWidth="58.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="2" />
<String fx:value="3" />
<String fx:value="4" />
</FXCollections>
</items>
</ComboBox>
<Label fx:id="WelshWord1" layoutX="343.0" layoutY="122.0" text="Welsh word#3" />
<Label fx:id="WelshWord2" layoutX="343.0" layoutY="157.0" text="Welsh word#2" />
<Label fx:id="WelshWord3" layoutX="343.0" layoutY="192.0" text="Welsh word#1" />
<Label fx:id="WelshWord4" layoutX="343.0" layoutY="227.0" text="Welsh word#4" />
<Label fx:id="EngWord1" layoutX="115.0" layoutY="122.0" text="English Word #1" />
<Label fx:id="EngWord2" layoutX="115.0" layoutY="157.0" text="English Word #2" />
<Label fx:id="EngWord3" layoutX="115.0" layoutY="192.0" text="English Word #3" />
<Label fx:id="EngWord4" layoutX="115.0" layoutY="227.0" text="English Word #4" />
<Label layoutX="105.0" layoutY="122.0" text="1." />
<Label layoutX="105.0" layoutY="157.0" text="2." />
<Label layoutX="105.0" layoutY="192.0" text="3." />
<Label layoutX="105.0" layoutY="227.0" text="4." />
<Label layoutX="367.0" layoutY="23.0" text="Correct answers:" />
<Label layoutX="368.0" layoutY="53.0" text="Wrong answers:" />
<Label fx:id="CorrectAnswer" layoutX="463.0" layoutY="23.0" text="0" />
<Label fx:id="WrongAnswer" layoutX="463.0" layoutY="53.0" text="0" />
</children>
</Pane>

View file

@ -0,0 +1,135 @@
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import java.net.URL;
import java.util.*;
public class MyController implements Initializable {
private Random rand = new Random();
public LinkedList<DictionaryEntry> setOfQuestions=new LinkedList<>();
private ArrayList<Integer> temp1 = new ArrayList<>(Arrays.asList(0,1,2,3));
int corAns = 0;
int wrongAns = 0;
@FXML
private ComboBox<String> word1;
@FXML
private ComboBox<String> word2;
@FXML
private ComboBox<String> word3;
@FXML
private ComboBox<String> word4;
@FXML
private Label EngWord1;
@FXML
private Label EngWord2;
@FXML
private Label EngWord3;
@FXML
private Label EngWord4;
@FXML
private Label WelshWord1;
@FXML
private Label WelshWord2;
@FXML
private Label WelshWord3;
@FXML
private Label WelshWord4;
@FXML
private Label CorrectAnswer;
@FXML
private Label WrongAnswer;
private void TestLabel(LinkedList<DictionaryEntry> questions, ArrayList<Integer> randOrder){
EngWord1.setText(questions.get(0).getEnglish());
EngWord2.setText(questions.get(1).getEnglish());
EngWord3.setText(questions.get(2).getEnglish());
EngWord4.setText(questions.get(3).getEnglish());
Collections.shuffle(randOrder);
WelshWord1.setText(questions.get(randOrder.get(0)).getWelsh());
WelshWord2.setText(questions.get(randOrder.get(1)).getWelsh());
WelshWord3.setText(questions.get(randOrder.get(2)).getWelsh());
WelshWord4.setText(questions.get(randOrder.get(3)).getWelsh());
}
private LinkedList<DictionaryEntry> getQuestions(LinkedList<DictionaryEntry> dictionary){
do{
int rand_q=rand.nextInt(dictionary.size()-1);
DictionaryEntry pickedQuestion = dictionary.get(rand_q);
if(setOfQuestions.size()>1){
for(int i=0;i<setOfQuestions.size();i++){
if(setOfQuestions.get(i).equals(pickedQuestion)){
break;
}else {
setOfQuestions.add(pickedQuestion);
}
}
}else{
setOfQuestions.add(pickedQuestion);
}
}while(setOfQuestions.size()<5);
return setOfQuestions;
}
private void fill(){
setOfQuestions.add(new DictionaryEntry("abbey", "abaty", "nm"));
setOfQuestions.add(new DictionaryEntry("believe", "credu", "verb"));
setOfQuestions.add(new DictionaryEntry("concert", "cyngerdd", "nm"));
setOfQuestions.add(new DictionaryEntry("disease", "clefyd", "nm"));
}
public void checkAnswers(){
int w1 = Integer.parseInt(word1.getValue())-1;
int w2 = Integer.parseInt(word2.getValue())-1;
int w3 = Integer.parseInt(word3.getValue())-1;
int w4 = Integer.parseInt(word4.getValue())-1;
if(setOfQuestions.get(w1).getWelsh().equals(WelshWord1.getText())){
corAns++;
}else wrongAns++;
if(setOfQuestions.get(w2).getWelsh().equals(WelshWord2.getText())){
corAns++;
}else wrongAns++;
if(setOfQuestions.get(w3).getWelsh().equals(WelshWord3.getText())){
corAns++;
}else wrongAns++;
if(setOfQuestions.get(w4).getWelsh().equals(WelshWord4.getText())){
corAns++;
}else wrongAns++;
CorrectAnswer.setText(Integer.toString(corAns));
WrongAnswer.setText(Integer.toString(wrongAns));
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
this.fill();
TestLabel(setOfQuestions,temp1);
}
}