Guest User

Untitled

a guest
Apr 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.42 KB | None | 0 0
  1. // @Author: Jordan Fisher
  2. // @Version: 1.1
  3.  
  4. import java.awt.BorderLayout;
  5. import java.awt.FlowLayout;
  6. import java.awt.Dimension;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.util.Random;
  10. import javax.swing.JFrame;
  11. import javax.swing.JPanel;
  12. import javax.swing.JTextField;
  13. import javax.swing.JButton;
  14.  
  15. public class French extends JFrame implements ActionListener {
  16.     JPanel panel = new JPanel();
  17.     JTextField question = new JTextField("Start by saying your speech");
  18.     JTextField englishTranslation = new JTextField("<<English translation>>");
  19.     JButton newQuestion = new JButton("New Question");
  20.     JButton showEnglish = new JButton("Show English translation");
  21.    
  22.     public String reference;
  23.     public int random;
  24.    
  25.     Random myRandom = new Random();
  26.    
  27.     public French() {
  28.         panel.setLayout(new FlowLayout());
  29.         panel.add(newQuestion, BorderLayout.WEST);
  30.         panel.add(showEnglish, BorderLayout.EAST);
  31.        
  32.         getContentPane().add(question, BorderLayout.NORTH);
  33.         getContentPane().add(englishTranslation, BorderLayout.CENTER);
  34.         getContentPane().add(panel, BorderLayout.SOUTH);
  35.        
  36.         setTitle("French Speaking revision..");
  37.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  38.        
  39.         newQuestion.addActionListener(this);
  40.         showEnglish.addActionListener(this);
  41.        
  42.         question.setEditable(false);
  43.         englishTranslation.setEditable(false);
  44.        
  45.         question.setHorizontalAlignment(JTextField.CENTER);
  46.         englishTranslation.setHorizontalAlignment(JTextField.CENTER);
  47.     }
  48.     public static void main(String[] args) {
  49.         French frame = new French();
  50.         frame.setLocation(100, 100);
  51.         frame.pack();
  52.        
  53.         frame.setVisible(true);
  54.     }
  55.     public void actionPerformed(ActionEvent e) {
  56.         if (e.getSource() == newQuestion) {
  57.             random = myRandom.nextInt(17) + 1;
  58.             switch (random) {
  59.                 case 1:
  60.                     question.setText("Quelle as-tu fait ton stage?");
  61.                     reference = "What did you do for your work experience?";
  62.                     break;
  63.                 case 2:
  64.                     question.setText("Quand as-tu fait ton stage?");
  65.                     reference = "When did you do for your work experience?";
  66.                     break;
  67.                 case 3:
  68.                     question.setText("Oú as-tu fait ton stage?");
  69.                     reference = "Where did you do for your work experience?";
  70.                     break;
  71.                 case 4:
  72.                     question.setText("Pourquoi as-du fait ton stage");
  73.                     reference = "Why did you do your work experience?";
  74.                     break;
  75.                 case 5:
  76.                     question.setText("Tu te léves a quelle heures?");
  77.                     reference = "What time do you get up?";
  78.                     break;
  79.                 case 6:
  80.                     question.setText("Tu quittes la maison avec qui?");
  81.                     reference = "You leave the house with who?";
  82.                     break;
  83.                 case 7:
  84.                     question.setText("Comment as-tu voyage?");
  85.                     reference = "How did you travel?";
  86.                     break;
  87.                 case 8:
  88.                     question.setText("Avec qui as-tu travaillé?");
  89.                     reference = "Who did you work with?";
  90.                     break;
  91.                 case 9:
  92.                     question.setText("Peux-tu decrire ton patron?");
  93.                     reference = "Can you describe your boss?";
  94.                     break;
  95.                 case 10:
  96.                     question.setText("Tu as un job?");
  97.                     reference = "You have a job?";
  98.                     break;
  99.                 case 11:
  100.                     question.setText("Quélle était ton opinion de ton stage?");
  101.                     reference = "What was your opinion of your work experience?";
  102.                     break;
  103.                 case 12:
  104.                     question.setText("Quelle as-ton amis pensé de ton stage?");
  105.                     reference = "What did your friend think of your work experience?";
  106.                     break;
  107.                 case 13:
  108.                     question.setText("A quelle heures as-tu finis ton stage?");
  109.                     reference = "What time did you finish your work experience?";
  110.                     break;
  111.                 case 14:
  112.                     question.setText("Peux-tu decrire ton stage?");
  113.                     reference = "Can you describe your work experience?";
  114.                     break;
  115.                 case 15:
  116.                     question.setText("Est-ce tu aimerais fair ca comme carriére?");
  117.                     reference = "Would you like to do that job as a career?";
  118.                     break;
  119.                 case 16:
  120.                     question.setText("A quelle heures as-ton stage commencé?");
  121.                     reference = "What time did your work experience start?";
  122.                     break;
  123.                 case 17:
  124.                     question.setText("Quellé était ton routiné pour ton stage?");
  125.                     reference = "What was your routine for your work experience?";
  126.                     break;
  127.                 default:
  128.                     question.setText("Merdé. C'est un problemé");
  129.                     reference = "Shit. There is a problem";
  130.                     break;
  131.             }
  132.             englishTranslation.setText("");
  133.         } else if (e.getSource() == showEnglish) {
  134.             englishTranslation.setText(reference);
  135.         }
  136.     }
  137. }
Add Comment
Please, Sign In to add comment