Skip to content

Review 1 #1

@tshemsedinov

Description

@tshemsedinov
  • Improve naming, that's extremely bad naming:
    JLabel questionText = new JLabel("Question text");
    JTextField question = new JTextField();
    JLabel optionText = new JLabel("options");
    JTextField option1 = new JTextField();
    JTextField option2 = new JTextField();
    JTextField option3 = new JTextField();
    JTextField option4 = new JTextField();
    JButton add = new JButton("Add question");
    JButton clear = new JButton("Clear all questions");
    JButton done = new JButton("Done");
    JRadioButton r1 = new JRadioButton();
    JRadioButton r2 = new JRadioButton();
    JRadioButton r3 = new JRadioButton();
    JRadioButton r4 = new JRadioButton();
    ButtonGroup bg = new ButtonGroup();
    JLabel empty = new JLabel("");
    ArrayList<String> questions = new ArrayList<>();
    ArrayList<String[]> options = new ArrayList<>();
    ArrayList<String> correctAns = new ArrayList<>();
  • Magic numbers:
  • Code duplication:
    • if(e.getSource() == option1) {
      if(option1.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
      }
      if(e.getSource() == option2) {
      if(option2.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
      }
      if(e.getSource() == option3) {
      if(option3.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
      }
      if(e.getSource() == option4) {
      if(option4.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
    • if(e.getSource() == option1) {
      if(option1.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
      }
      if(e.getSource() == option2) {
      if(option2.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
      }
      if(e.getSource() == option3) {
      if(option3.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
      }
      if(e.getSource() == option4) {
      if(option4.getText().equals(correctAns.get(index))) {
      correctGuesses++;
      }
      index++;
      nextQuestion();
  • No interesting code, add something except bolerplates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions