package glossary.gui;

import glossary.engine.facade.WritingTestFacade;
import glossary.engine.model.Card;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * Created by Papi on 6. 7. 2017.
 */
public class WritingTestPanel extends JPanel{

    private JTextField translation;
    private JLabel  word;
    public WritingTestPanel(LayoutManager layout) {
        super(layout);
    }

    public void init(){
        word = new JLabel("WORD");
        JLabel lAnswer = new JLabel("Your answer is:");
        translation = new JTextField("CUSTOM TRANSLATION");
        JButton buttonNext = new JButton("Next");
        Dimension dim;
        Rectangle rec;


        dim = new Dimension(400, 100);
        rec = new Rectangle(100, 100, dim.width, dim.height);
        word.setBounds(rec);
        word.setFont(new Font("Arial", Font.BOLD, 30));

        dim = new Dimension(600, 80);
        rec = new Rectangle(100,240 , dim.width, dim.height);
        lAnswer.setFont(new Font("Arial", Font.BOLD, 20));
        lAnswer.setBounds(rec);

        dim = new Dimension(600, 50);
        rec = new Rectangle(100, 350, dim.width, dim.height);
        translation.setBounds(rec);

        dim = new Dimension(200,80);
        rec = new Rectangle(500, 400, dim.width, dim.height);
        buttonNext.setBounds(rec);



        add(word);
        add(translation);
        add(lAnswer);
        add(buttonNext);

        buttonNext.addActionListener((ActionEvent e) -> {
        continueTest();
        });
    }
    public void startTest(WritingTestFacade facade){
        Card card = facade.getNext();
        word.setText(card.getWord1());
        translation.setText("");
    }

    public void continueTest(){
        String customAnswer = translation.getText();


    }


}

@@ -329,16 +329,79 @@
   word;%0A
+    private JLabel hint;%0A    private WritingTestFacade facade;%0A
     publ
@@ -466,32 +466,33 @@
 layout);%0A    %7D%0A%0A
+%0A
     public void 
@@ -696,24 +696,59 @@
 on(%22Next%22);%0A
+        hint = new JLabel(%22HINT%22);%0A
         Dime
@@ -1434,16 +1434,201 @@
 (rec);%0A%0A
+        dim = new Dimension(400,100);%0A        rec = new Rectangle(100, 400, dim.width, dim.height);%0A        hint.setFont(new Font(%22Arial%22, Font.BOLD, 15));%0A        hint.setBounds(rec);%0A
 %0A%0A      
@@ -1713,16 +1713,67 @@
 nNext);%0A
+        add(hint);%0A%0A        hint.setVisible(false);
 %0A       
@@ -1930,107 +1930,54 @@
     
-Card card = facade.getNext();%0A        word.setText(card.getWord1());%0A        translation.setText(%22%22
+this.facade = facade;%0A        prepareQuestion(
 );%0A 
@@ -2010,24 +2010,56 @@
 inueTest()%7B%0A
+        hint.setVisible(false);%0A
         Stri
@@ -2099,17 +2099,489 @@
 Text();%0A
-%0A
+        if (facade.verify(customAnswer))%7B%0A            prepareQuestion();%0A        %7D else %7B%0A            hint.setText(%22HINT: %22+facade.getAnswer());%0A            hint.setVisible(true);%0A        %7D%0A    %7D%0A%0A    private void prepareQuestion()%7B%0A        Card card = facade.getNext();%0A        if (card == null)%7B%0A            finish();%0A        %7D%0A        word.setText(card.getWord1());%0A        translation.setText(%22%22);%0A    %7D%0A%0A    private void finish()%7B%0A        System.out.println(%22Finish%22);
 %0A    %7D%0A%0A

Improve testing